I'm developing on Linux/g++ and uses valgrind to verify memory usage. My question is: How do I know where there is an allocation of memory in my application (including system libraries)? May be valgrind provides this functionality, or some similar tool.
Asked
Active
Viewed 228 times
1
-
When you run valgrind, it should tell you where there is allocations/free's – Tony The Lion Nov 12 '11 at 00:10
-
Or do you want to track this yourself? Your question isn't very clear. – Tony The Lion Nov 12 '11 at 00:10
-
If no memory error (allocs == frees), then no messages about memory usage, but I want to know about allocations in any case. – Andrii Nov 12 '11 at 00:19
-
... and where it happens – Andrii Nov 12 '11 at 00:19
3 Answers
2
If you want to profile memory usage, have a look at massif (valgrind tool). Also try the excellent massif visualizer to visualize the results.

Frank Osterfeld
- 24,815
- 5
- 58
- 70
0
gdb will allow you to monitor a specific memory section for writes and reads. You can set a break point on this. You can use the gdb 'watch' command.

Adrian Cornish
- 23,227
- 13
- 61
- 77
0
I think you are looking for --trace-malloc=yes
.

Karoly Horvath
- 94,607
- 11
- 117
- 176
-
Yes, it looks like what I need, but output looks like "_Znaj(128) = 0x42FF060". Can I show it as a more readable? – Andrii Nov 12 '11 at 00:41