I write my project by c with opencv. I want print info about allocated memory or memory used by my program. Is there a functions, that give me the information about the memory ? Finally I'm using Qt for Linux and Windows ,
Thanks in advance.
I write my project by c with opencv. I want print info about allocated memory or memory used by my program. Is there a functions, that give me the information about the memory ? Finally I'm using Qt for Linux and Windows ,
Thanks in advance.
You can write wrappers to malloc and free that track how much memory you're using.
EDIT: If you also want to intercept calls to malloc and free in external libraries, you will have to define them in a shared library and load it before libc. How you do this depends on your OS.
On Linux you look into your own process info pseudo-file:
/proc/[pid]/statm
Provides information about memory usage, measured in pages. The columns are:
size total program size
(same as VmSize in /proc/[pid]/status)
resident resident set size
(same as VmRSS in /proc/[pid]/status)
share shared pages (from shared mappings)
text text (code)
lib library (unused in Linux 2.6)
data data + stack
dt dirty pages (unused in Linux 2.6)
On Windows you look at you own process Process Object performance counters:
Private BytesShows the current number of bytes that this process has allocated that cannot be shared with other processes.
You can also do some level of memory analysis of Code/Data segment during build time if you check elf, dump or map file. And GCC command line options for stack usage are: -fstack-usage and -fcallgraph-info.