Hi,
John Kelso wrote:
Hi Robert,
I must admit I used a pretty simplistic method. While running my app
I run
"top" in another window and look at the process' virtual memory size.
When running without the merge the virtual memory size never changes.
When
running with the merge, the size steadily increases. After about 16,000
merges my malloc's fail and the process crashes.
I too looked at the merge code and didn't see anything obvious.
I have the feeling that I'm doing something fundamentally wrong that
will be
embarrassingly obvious in hindsight, but for now has me stumped. I'm
waiting
for the "Ah ha" moment to strike.
If you can suggest any tests to run, or have any other suggestions, it
would
be appreciated.
Try using valgrind's massif. It makes snapshots of a program's heap
allocation during its lifetime and
can report for each snapshot where the memory was allocated. Here's an
example:
14:40|p...@tabu:~/cppexamples> cat osg_leak.cpp
// example leaky program
// g++ -o oll osg_leak.cpp -I ~/osg2.8/include/ -L ~/osg2.8/lib/ -losg
-losgDB
#include <osg/Group>
int main()
{
osg::Group* group;
for (int i = 0; i < 100000; i++)
group = new osg::Group;
}
14:40|p...@tabu:~/cppexamples> g++ -g -o leak osg_leak.cpp -I
~/osg2.8/include/ -L ~/osg2.8/lib/ -losg -losgDB
14:40|p...@tabu:~/cppexamples> valgrind --tool=massif ./leak
[...]
14:41|p...@tabu:~/cppexamples> ls -ltr
[...]
-rw------- 1 paul paul 14848 Jun 4 14:41 massif.out.11415
14:41|p...@tabu:~/cppexamples> ms_print massif.out.11415
# actual output contains much more, including a nice graph
# of memory consumption over time ;-)
[...]
--------------------------------------------------------------------------------
n time(i) total(B) useful-heap(B) extra-heap(B)
stacks(B)
--------------------------------------------------------------------------------
79 47,051,074 21,761,128 18,959,969
2,801,159 0
87.13% (18,959,969B) (heap allocation functions) malloc/new/new[],
--alloc-fns, etc.
->66.17% (14,400,000B) 0x80486BD: main (osg_leak.cpp:7)
->12.87% (2,800,336B) 0x4378576: OpenThreads::Mutex::Mutex()
(PThreadMutex.c++:38)
->03.68% (800,008B) 0x41C83C4: osg::Referenced::Referenced(bool)
(Referenced.cpp:180)
->02.56% (557,370B) in 21 places, all below massif's threshold (01.00%)
->01.85% (402,255B) 0x92F65C: (within /usr/lib/libGL.so.96.43.01)
Regards,
Paul
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org