Incredibly high memory problems

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?

extra details:
-program is using opengl
-running windows 7
Last edited on
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).
Thank you soranz.
While I continue to search for cases of memory not cleaned up, I'm still wondering if there's another way for memory usage to increase?
Not that I know of...but I can't say I am 100% sure about that...
It's 99% that you have objects which you allocate with new but never delete. (I can't think of anything else at the moment which could cause such memory leak).

You're most likely using raw pointers ( like :MyObject *obj = new MyObject; ).

Start using smart pointers like std::shared_ptr().
Using these you will be able to avoid memory leaks, without any headaches.
Thank you for your help soranz and romai. I found an if statement that was leaking a lot of memory. And so now, my program climbs up to just 9,000 KB maximum, thanks to this fix!
Topic archived. No new replies allowed.