I have a program that, by the looks of task manager, gains 10,000 KB of memory a seconds non-stop until it hits about 2,000,000 KB and comes to a complete halt.
I read that memory can stack up like this when object pointers aren't dealt with properly. My program is a physics engine in progress so the only classes I have are vectors and objects. An object so far is never deleted or scoped out of. However, there certainly is a lot of vectors being scoped out of.
So I made sure that every single vector was deleted. The memory is now climbing at 2,000 KB a second. That was a huge part of the problem, but not all of it.
Anyways, my questions are:
1. Are there any other ways of stopping the memory climb besides deleting objects?
2. Is simply deleting an object pointer enough to clear up memory the object was taking?
-program is using opengl
-running windows 7
The more objects u instantiate, the more memory they're gonna gobble up. Pass by reference/pointer into functions to minimize copies...the bigger vectors get - the more they're going to demand too. Make sure all unused objects are cleaned up right away.
Just FYI, if u'r using pointers to vectors, clear() will not call the delete operator and u'll have to call delete urself (learned the hard way).