I have created an application in C++ using visual studio. And as per my application it should take very less memory but it is taking very much memory. So, now I want to know memory map function wise. Is there any way in Visual Studio to generate memory map or any other tool or any other way to generate memory map. Please Reply soon.
Thanks in Advance.
Mayank
You could try using Visual Leak Detector. It will not give you function wise memory usage but will highlight leaked memory traces in the debugger output. You'll have to play around a bit go get used to it.
I believe it is more operating system specific than language or compiler specific.
On Linux, you can read (from inside your process) the /proc/self/maps
to understand the memory map of your application.
% cat /proc/self/maps
00400000-0040c000 r-xp 00000000 08:01 2334758 /bin/cat
0060c000-0060d000 rw-p 0000c000 08:01 2334758 /bin/cat
012fd000-0131e000 rw-p 00000000 00:00 0 [heap]
7f1714cf2000-7f1715009000 r--p 00000000 08:01 3932623 /usr/lib/locale/locale-archive
7f1715009000-7f1715183000 r-xp 00000000 08:01 3892787 /lib/x86_64-linux-gnu/libc-2.13.so
7f1715183000-7f1715383000 ---p 0017a000 08:01 3892787 /lib/x86_64-linux-gnu/libc-2.13.so
7f1715383000-7f1715387000 r--p 0017a000 08:01 3892787 /lib/x86_64-linux-gnu/libc-2.13.so
7f1715387000-7f1715388000 rw-p 0017e000 08:01 3892787 /lib/x86_64-linux-gnu/libc-2.13.so
7f1715388000-7f171538d000 rw-p 00000000 00:00 0
7f171538d000-7f17153ac000 r-xp 00000000 08:01 3892902 /lib/x86_64-linux-gnu/ld-2.13.so
7f1715589000-7f171558c000 rw-p 00000000 00:00 0
7f17155aa000-7f17155ac000 rw-p 00000000 00:00 0
7f17155ac000-7f17155ad000 r--p 0001f000 08:01 3892902 /lib/x86_64-linux-gnu/ld-2.13.so
7f17155ad000-7f17155ae000 rw-p 00020000 08:01 3892902 /lib/x86_64-linux-gnu/ld-2.13.so
7f17155ae000-7f17155af000 rw-p 00000000 00:00 0
7fff374d2000-7fff374f3000 rw-p 00000000 00:00 0 [stack]
7fff3750c000-7fff3750d000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
The above example shows the memory map of the process executing the cat
command.
EDIT
Don't expect to find memory use by function, since memory usage of a given data is a global property of the program (so the very notion of memory usage per function has no sense). You could use some garbage collection technique. And you could (at least on Linux) use Boehm's garbage collector, or write your own GC, or hunt memory leaks with valgrind (or a similar program for your system).
You have to find out if your operating system gives you an equivalent facility.
(I don't know and don't use Windows, so I cannot help more)