简体   繁体   中英

At runtime, how can I determine programmatically how much memory is used by dynamically-linked libraries?

I want to find out how much memory my application is using. I also want to know what part of my program is using the most memory. For example, I have a process that uses 100MB of memory, there is a .dll in that process that is using 90MB of memory. I would like to know "what" .dll takes that 90MB.

I want to take this value and use it in my program; I want to make a server where you can view the memory usage of separate parts.

This application is going to run on Windows.

The question is utterly operating system dependent.

(I assume that DLL translates to dynamically loaded libraries and ELF shared objects in the Linux world)

For a Linux application, your application can sequentially read the /proc/self/maps textual pseudo-file.

If you know that your application process id is 1234, you can also read the /proc/1234/maps file, eg by typing in a terminal

 cat /proc/1234/maps

There are also /proc/self/smaps and /proc/1234/smaps which are slightly more detailed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM