Help Memory Usage Again
Blitz3D Forums/Blitz3D Beginners Area/Help Memory Usage Again
| ||
Since I was told type instances are not freed from memory until the end of the program, but saved for later use. However if I create say 100 players, delete the 100 players, and recreate a 100 players the memory is not reused. Is their a better way to do this, I'm still eat 4k(according to task manager) everytime i eat a player, of course thats not much memory but. If I run this It doesn't reuse the memory, but keeps eating it. ;create all players dim p.player(1000) for x=1 to 100 p(x)=new player p(x)\stuff=stuff next ;delete all players for pk.player=each player delete pk next ;recreate all players for x=1 to 100 p(x)=new player p(x)\stuff=stuff next If the memorys saved for later use, shouldn't that reuse the memory? I also tried creating each new instance of player at startup, then just changing the status to offline, so no delete, and no new player, however it still loses memory. Is their anything I can do? |
| ||
Trying this test program:Type player Field stuff End Type Dim p.player(1000) For iteration = 1 To 5 Print iteration WaitKey ;create all players For x=1 To 100 p(x)=New player p(x)\stuff=1 Next WaitKey ;delete all players For pk.player=Each player Delete pk Next Next The memory goes up 1 time only (the first time) by about 32 kilobytes. After that, it stays put. It appears that the memory is being reused. Are you sure you are not leaving some memory hanging, like a type within a type, or a media handle (image, sound)? |