memory management - C++, Leak or not? what can be done -


we have program crashes @ 4gb due insufficient memory after running long period of time. project in c++, opensuse11,12, including linking various shared memories , other libraries.

monitoring heap increase , total memory increase pmap of pid, totally analogous. meaning process starts 2.5gb , heap ~0 , , before crashing total = 4 gb , heap = 1.5 gb.

we have made runs valgrind , result quite puzzling. below can see summaries running 20 minutes.

==30042== heap summary: ==30042==     in use @ exit: 706,413 bytes in 3,345 blocks ==30042==   total heap usage: 1,770,240 allocs, 1,766,895 frees, 173,813,303 bytes allocated  ==30042== leak summary: ==30042==    lost: 96 bytes in 3 blocks ==30042==    indirectly lost: 27 bytes in 3 blocks ==30042==      possibly lost: 344 bytes in 2 blocks ==30042==    still reachable: 705,946 bytes in 3,337 blocks ==30042==                       of reachable via heuristic: ==30042==                         stdstring          : 62 bytes in 2 blocks ==30042==         suppressed: 0 bytes in 0 blocks 

monitoring pmap, know total memory increased 130 mb comparing valgrind report, can see there leaks nothing close 130 mb.

now questions:

  • can me understand valgrind summary , how can relate 130 mb lost ?

  • is leak or not ?

  • does valgrind report going on inside shared memories ?
  • even if there leak in sm, wouldn't still in heap in them? sizes in reasonable levels.
  • i have read in various sources, when freeing memory delete[] or free() system still may keep space reserved future use. if case, can done ?

*edit place heap usage seems unrestricted when program server, makes calls db (solid sql) large data continuously, allocates lot of space. not in shared memory. , see frees correctly managed, can done ?

take @ massif tool in valgrind suite. heap profiler understand how program continues grow without bound. unlimited growth appears problem rather leaking.

can me understand valgrind summary , how can relate 130 mb lost ?

valgrind indicates program used 170mb of heap not far number. longer runs show ever increasing maximum heap size.

is leak or not ?

the report not indicate in way of leaks. appears program cleans pretty well. peak heap usage seems issue.

does valgrind report going on inside shared memories ?

no, valgrind looks @ heap memory process local.

even if there leak in sm, wouldn't still in heap in them? sizes in reasonable levels.

no, shared memory not heap memory. ipcs , other tools can show amount of shared memory being used. total addressable space of 32-bit process 4gb amount of shared memory mapped process can reduce amount of heap space available.

i have read in various sources, when freeing memory delete[] or free() system still may keep space reserved future use. if case, can done ?

yes accurate. once memory allocated process not returned os until process exits. heap reused repeatedly in process maximum size of heap not increase unless in use. nothing can done @ user level , not problem.

to reiterate, data structure in program growing without bound. example, linked list being endlessly added to. since data still reachable, not technically leak , not show in valgrind report. heap profiler, massif, can point areas in source code allocate large amounts of heap memory.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -