|
From: sachin g. <g_s...@ya...> - 2011-11-18 16:32:48
|
Hi All,
I have a simple program
/*************************/
#include <iostream>
#include <string>
main()
{
std::string test;
test ="abc";
std::string *test2 = new std::string("abc");
delete test2;
}
/******************************************/
Now I am running valgrind over it
valgrind --tool=massif ./a.out
on ms_print
it is howing output as
/****************************************
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
--------------------------------------------------------------------------------
0 0 0 0 0 0
1 1,385,421 40 28 12 0
2 1,388,597 64 36 28 0
3 1,389,777 104 64 40 0
4 1,393,400 104 64 40 0
61.54% (64B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
->53.85% (56B) 0x3D1709B85F: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.8)
| ->26.92% (28B) 0x3D1709D10F: std::string::_M_mutate(unsigned long, unsigned long, unsigned long) (in /usr/lib64/libstdc++.so.6.0.8)
| | ->26.92% (28B) 0x3D1709D28A: std::string::_M_replace_safe(unsigned long, unsigned long, char const*, unsigned long) (in /usr/lib64/libstdc++.so.6.0.8)
| | ->26.92% (28B) 0x4009B2: main (test1.c:6)
| |
| ->26.92% (28B) 0x3D1709C363: ??? (in /usr/lib64/libstdc++.so.6.0.8)
| ->26.92% (28B) 0x3D1709C510: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.8)
| ->26.92% (28B) 0x4009E3: main (test1.c:8)
|
->07.69% (8B) 0x4009CD: main (test1.c:8)
/*********************
Why valgrind is showing stack variables in heap. Any idea.
Regards
Sachn
|