I am beginner and I am looking for some help for measuring how much memory a specific program is taking to complete its execution? Is there any article or built in functions I need to start with.
closed as off-topic by Ghanima♦ Oct 6 '16 at 14:57
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – Ghanima
You may want to start by running
top and locating your program in the list. It will look similar to this:
As you can see, there are 3 different memory metrics, each with its own gotchas:
- VIRT - this is virtual memory, which lists all the addresses your program is allowed to access. As its name suggests, it doesn't have to be fully backed by actual RAM. However, if your program does access all these addresses, it will be able to consume this much without requesting any new memory from the system.
- RES - this is how much of your program's memory stays resident in RAM. If you have swap enabled, this value will depend not only on your program's behaviour, but also on the swapping strategy.
- SHR - this is how much resident memory your program shares with other processes (the most typical example is shared libraries). When your program stops using some of this memory, its SHR and RES values will go down but no actual memory will be freed.
Hope this clears some things up.