| I am developing an application where thousands of objects need to be stored in memory (and later removed) but it crashes because the memory is not deallocated.|
Ok, there are a few problems here.
1 ... thousands are small, and will fit in a single vector. Reserve more than you need, 10k, whatever, these are small values unless you are on an embedded potato machine. 10k of a 100 byte sized object is only a megabyte. There are simply far better ways than dynamic memory.
2) not delete will never crash your program. Running the machine out of memory will, and accessing invalid pointers will, and various other things, but not deleting will not. Leaking memory, akin to running the machine out of memory, will. Something else is wrong.
3) if you are doing this over and over again, stop. Keep the memory around and reuse it, allocate and free are slow. Clear out the old data and refill it if you must (would be nice if this were also mostly valid and you can just update it).
4) if you free or delete it, set it to nullptr. If it crashes again, it will TELL you that you tapped a null pointer (dereference) or if you free it again it will do no harm (safe to delete null all day long).
It does look like you are on some odd machine -- 400MB is not even a phone these days --- if you care to enlighten us a bit more it may help.