top tip for flushmem, null and scope

BlitzMax Forums/BlitzMax Tutorials/top tip for flushmem, null and scope

Robert Cummings(Posted 2005) [#1]
Often, people using Blitzmax will get a bit unsure if they're doing the null thing right. Sometimes you'll think "how do I know if it's REALLY deleted?"

Or perhaps you don't think flushmem is in the right place, or being used out of scope?

Regardless of your reasons, when developing your game, the golden tip is to put

	Drawtext "memory: "+memalloced() , 0 , 0


Right there in your render code. I hear a chorus of "oh yeah I knew that..." but I doubt you practise it.

It's invaluable, and you can watch it while you're doing very many things. Often you might wonder why it's slowing down. Watching the memory count rise incredibly fast is a clue! Regardless, this is my top tip number one!


Dreamora(Posted 2005) [#2]
When stuff is programmed correctly (remove methods in objects and a TList per type which is the only handling instance for type instances), this kind of work is not needed, as long as there is a flushmem after flip in the mainloop


ashmantle(Posted 2005) [#3]
when is ever stuff programmed correctly? ^^ I believe thats why we have a term called bugs.

But its nice to keep track of the linked lists and so on in the beginning of the development.


JazzieB(Posted 2005) [#4]
When stuff is programmed correctly (remove methods in objects and a TList per type which is the only handling instance for type instances), this kind of work is not needed, as long as there is a flushmem after flip in the mainloop


Actually, I just had an instance where I needed an additional FlushMem from the one after Flip. I was watching my memory consumption going up and I couldn't understand why, as I was not creating any more Types during the game loop. I eventually tracked it down to the update Function/Method in the Type itself and solved the problem by putting a FlushMem after the For..EachIn loop.