I can't fully explain why you're seeing the behaviour you are (I suspect it may be something to do with an odd 2d array being returned but that is just my own wild theory) but there does seem to be a simple workaround.  If you use a foreach loop (which seems to fit what you need better anyway, although I could be wrong again!) it returns all of the values from the select, i.e.

&lt;xsl:for-each select="//pregunta"&gt;
  &lt;h3&gt;&lt;xsl:value-of select="position()" /&gt; : &lt;xsl:value-of select="@id" /&gt;&lt;/h3&gt;
&lt;/xsl:for-each&gt;


XPATH Selecting by position returns incoherent results
This can be easy for games with well defined scope, but the question is about sandbox games, where the player is allowed to create and build anything.

Possible techniques:


Use memory pools with upper limit.
Delete objects that are no longer needed periodically.
Allocate extra amount of memory at the beginning so it can be freed
later as a recovery mechanism. I would say around 2-4 MBs.


This is more likely to happen in mobile/console platforms where memory is usually limited unlike your 16 GB PC. I am assuming you have full control over memory allocation/deallocation and no garbage collection involved. That's why am tagging this as C++.

Please note that I am not talking about Effective C++ Item 7 "Be prepared for out-of-memory conditions", even though it's relevant, I would like to see an answer more related to game development, where you usually have more control over what's happening.

To summarize the question , how do you prepare for out of memory conditions for sandbox games, when you are targeting a platform with limited memory console/mobile ?
