Hi make some days someone wrote about make Redim[0] for free the array from memory...
I have a question, but I suppose I´m in the correct way...
If I do a Classe (Like MRTatoad comment in his book), I do using in example an array : my_Ene[5] and I do the Classe, where I have local variables, static variables, counters, drawsprite, and a lot of things....
When I do redim my_Ene[0], I free the memory in variables and all the things are into the Classe...
I have this doubt because I read if I do something like:
global spr_Shot I can´t free the memory for the variable... for Sprites sounds and media files it´s easy only putting loadsomething "noFile"
Thanks and sorry for this newbie question, but I´m not sure 100%
¿What's your question? I can't see it in your post :D
If you have an array of Types, if you redim the array and put less elements, the memory of the deleted elements are freed. But for example, if you open a file or load a sprite in the Type you must to close or unload the sprite before make the REDIM. GLBasic only takes care of the memory, the rest is for the programmer.
Global non-arrays can, of course, not be freed from memory (it would defeat the purpose of global variables if you could!). However, global arrays should be freed if a DIM
- is used because it is an array and whether it is local or global should make no difference about how it is treated.
The memory manager can only deal with things it knows about (arrays and so on, and so should free memory when needed), and whilst it may not be able to free graphics and stuff, the operating system should when the program is no longer running.
Btw if i remember right REDIM does not really free the memory, it keeps it allocated so you can use it for the same array faster again. If you really want to free the memory since you dont plan to use it for that specific array again, than better call DIM. Hope i remembered right about this.
Thanks guys... sorry I confused Redim whit DIm[0]
I think the answer for no Question =D of Hardyx help me... If you delete an Index in a Classe, the local and the other things go out from memory... Ok about the LoadSprite and all this things... I always do out of the loop... basically always I try to load something in real-time, the game stops a bit... whit a very low-weigth 3d Geometry Occurs equal... perhaps whit 15 or 30 Kb... but this not it's my case...
Thanks a lot!!!