Hello everybody.

I am trying to fully understand massif results.. I have the following code:

#include <string>
#include <unistd.h>


std::string *giveLargeObject ()
{
        return new std::string
("341234123412341234123412341234dfasfasdfassdfasdfasdfasdfasdfasdfasdfasdfasdfasdfaqddfasd");
}


int
main ()
{
        std::string *stringArray [100];
        for (unsigned int i = 0; i < 100; ++i)
                stringArray [i] = giveLargeObject ();

        sleep (1);

        for (unsigned int i = 0; i < 100; ++i)
                delete stringArray[i];

        return 0;
}


massif outputs the following:
== 0 ===========================
Heap allocation functions accounted for 53.1% of measured spacetime

Called from:
  51.1% : 0x40D9FFA: std::string::_Rep::_S_create(unsigned, unsigned,
std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.8)

   2.0% : 0x8048667: giveLargeObject() (massif1.cc:8)

== 1 ===========================
Context accounted for 51.1% of measured spacetime
  0x40D9FFA: std::string::_Rep::_S_create(unsigned, unsigned,
std::allocator<char> const&) (in /usr/lib/libstdc++.so.6.0.8)

Called from:
  51.1% : 0x40DAE14: (within /usr/lib/libstdc++.so.6.0.8)

---------------------------------
Context accounted for  2.0% of measured spacetime
  0x8048667: giveLargeObject() (massif1.cc:8)

Called from:
   2.0% : 0x80486FB: main (massif1.cc:17)


what I dont understand at all is that 2.0% accounted for giveLargeObject
()...I understand more heap memory its being allocated from
std::string::string constructor.. where else is consumed that 2.0% of heap
allocation?


I also dont understand at all the postscript output .. the fringe called
"stack(s)".. what massif means as stack? it is not supposed to be a heap
profiler?


Thanks in advance

Roberto.
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to