Memory Saving...?
BlitzMax Forums/BlitzMax Programming/Memory Saving...?
| ||
Hi, Trying to save memory (and loading time) by creating a 'holding' object which will contain all/some of my game sprites that I load up. Now if I want to pass those sprites along to be used by another object, and use something like newobject.sprites = holderobject.sprites Is that saving memory? ie is it passing a link to the sprites, or is it duplicating the data? Not too sure what's happening inside... -> Is it better to use some kind of pointer? (Never used those before so not too sure..) Any insight is appriciated. Thanks, KrayzBlu |
| ||
Function calls with objects and object assignment in BMax is pass by reference, so basically you are using a sort of "pointer" in the assignment above (i.e. newobject.sprites will now reference the exact same object as holderobject.sprites) The only time data is copied in an assignment or function call is when the object is a string (a new string is created) or the parameter or object in question is one of the built-in types (ints and floats are copied, for instance). |
| ||
Ok, that does it then. Thanks! |