Cleaning my memory wenn shutting down programm
-
hi, I'm developing a program that uses linked list's as a cover for the database. So i have list's of >1000 struct's. wenn i shut down my program i get memory dumps:
C:\projecten\PLCServer 0.2\DBVoorraadBeheer.cpp(63) : {3263} normal block at 0x06B95498, 44 bytes long. Data: < dU U U > 01 00 00 00 64 55 B9 06 0C 55 B9 06 BC 55 B9 06 strcore.cpp(118) : {3262} normal block at 0x06B95440, 15 bytes long. Data: < A > 01 00 00 00 01 00 00 00 02 00 00 00 41 00 00 strcore.cpp(118) : {3261} normal block at 0x06B953B8, 67 bytes long. Data: < 6 Spir> 01 00 00 00 1B 00 00 00 36 00 00 00 53 70 69 72 strcore.cpp(118) : {3260} normal block at 0x06B95360, 25 bytes long. Data: < 0700> 01 00 00 00 06 00 00 00 0C 00 00 00 30 37 30 30 strcore.cpp(118) : {3259} normal block at 0x06B95308, 25 bytes long. Data: < Cool> 01 00 00 00 06 00 00 00 0C 00 00 00 43 6F 6F 6C
how can i prevent this? []D [] []D [] -
hi, I'm developing a program that uses linked list's as a cover for the database. So i have list's of >1000 struct's. wenn i shut down my program i get memory dumps:
C:\projecten\PLCServer 0.2\DBVoorraadBeheer.cpp(63) : {3263} normal block at 0x06B95498, 44 bytes long. Data: < dU U U > 01 00 00 00 64 55 B9 06 0C 55 B9 06 BC 55 B9 06 strcore.cpp(118) : {3262} normal block at 0x06B95440, 15 bytes long. Data: < A > 01 00 00 00 01 00 00 00 02 00 00 00 41 00 00 strcore.cpp(118) : {3261} normal block at 0x06B953B8, 67 bytes long. Data: < 6 Spir> 01 00 00 00 1B 00 00 00 36 00 00 00 53 70 69 72 strcore.cpp(118) : {3260} normal block at 0x06B95360, 25 bytes long. Data: < 0700> 01 00 00 00 06 00 00 00 0C 00 00 00 30 37 30 30 strcore.cpp(118) : {3259} normal block at 0x06B95308, 25 bytes long. Data: < Cool> 01 00 00 00 06 00 00 00 0C 00 00 00 43 6F 6F 6C
how can i prevent this? []D [] []D []Willem B wrote: how can i prevent this? delete all objects/memory that you allocate with 'new' and free all memory you allocate with 'malloc'. -c
Image tools: ThumbNailer, Bobber, TIFFAssembler
-
Willem B wrote: how can i prevent this? delete all objects/memory that you allocate with 'new' and free all memory you allocate with 'malloc'. -c
Image tools: ThumbNailer, Bobber, TIFFAssembler
-
if you don't delete it, your program will leak memory. -c
Image tools: ThumbNailer, Bobber, TIFFAssembler
-
Willem B wrote: is it harmfull if i let the compiler delete it? It just won't do it: You told him that you wanted memory (
new
), got it (new
succeeded), and now you have to tell him that you dont want it anymore (delete
). If you want it automatic, then don'tnew
your variables! -
Anything allocated with new or malloc is not "deleted" by the compiler. It needs to be cleaned up with "delete", "free", or you can just let it happen when the program exits. However, if the program runs for a while, more and more memory may continue to be allocated and eventually you'll run out of it, causing the program to crash. The only memory the compiler cleans up automatically is the stack, which you can use to efficiently allocate any variable:
{
CString s = "allocated on the stack so it will be free automatically";
CString* p = new CString("allocated on the heap, needs to be freed with delete");delete p; // p must be cleaned up explicitly
} // s is automatically cleaned up hereRegards, Alvaro
When birds fly in the right formation, they need only exert half the effort. Even in nature, teamwork results in collective laziness. -- despair.com