When I fire command vmstat -s on my Linux box, I got stats as:

$ vmstat -s
16305800  total memory
16217112  used memory
9117400  active memory
6689116  inactive memory
88688  free memory
151280  buffer memory

I have skipped some details that is shown with this command.

I understand these terms: Active memory is memory that is being used by a particular process. Inactive memory is memory that was allocated to a process that is no longer running.

Just want to know, is there any way I can get the processes, with which inactive memory is allocated? Because top or vmstat command still shows the used memory as sum of active and inactive memory and I can see only processes that are using active memory but what processes are using inactive memory is still a question for me.

2 Answers 2


There are cases where looking at inactive memory is interesting, a high ratio of active to inactive memory can indicate memory pressure for example, but that condition is usually accompanied by paging/swapping which is easier to understand and observe. Another case is being able to observe a ramping up or saw-tooth for active memory over time – this can give you some forewarning of inefficient software (I've seen this with naïve software implementations exhibiting O(n) type behavior and performance degradation).

The file /proc/kpageflags contains a 64-bit bitmap for every physical memory page, you can get a summary with the program page-types which may come with your kernel.

Your understanding of active and inactive is incorrect however

  • active memory are pages which have been accessed "recently"
  • inactive memory are pages which have not been accessed "recently"

"recently" is not an absolute measure of time, but depends also on activity and memory pressure (you can read some of the technical details in the free book Understanding the Linux Virtual Memory Manager, Chapter 10 is relevant here), or the kernel documentation (pagemap.txt).

Each list is stored as an LRU (more or less). Inactive memory pages are good candidates for writing to the swapfile, either pre-emptively (before free memory pages are required) or when free memory drops below a configured limit and free pages are (expected to be imminently) needed.

Either flag applies to pages allocated to running processes, with the exception of persistent or shared memory all memory is freed when a process exits, it would be considered a bug otherwise.

This low level page flagging doesn't need to know the PID (and a memory page can have more than one PID with it mapped in any case), so the information required to provide the data you request isn't in one place.

To do this on a per-process basis you need to extract the virtual address ranges from /prod/PID/maps, convert to PFN (physical page) with /proc/PID/pagemap, and index into /proc/kpageflags. It's all described in pagemap.txt, and takes about 60-80 lines of C. Unless you are troubleshooting the VM system, the numbers aren't very interesting. One thing you could do is count the inactive and swap-backed pages per-process, these numbers should indicate processes which have a low RSS (resident) size compared with VSZ (total VM size). Another thing might be to infer a memory leak, but there are better tools for that task.


There is no such tool as it is completely pointless for any external program.

The only part of the system that needs to know that is the kernel's memory handler which will use it to know what to page (swap) out if it runs out of available memory.

The only related case that could cause any worries is if your swap becomes almost full. If that ever becomes the case, just increase it.

I've never seen actual problems that implied investigating on inactive memory.

  • 1
    Although the other answer has more words, nicer formatting and a lot of references, after examining my systems the conclusion is that this one is all you need to know. Active/inactive metric is useless. That being said I cannot agree with "worries" about full swap. It's not 1996, the swap should only contain truly useless stuff so I'd actually expect it to become full.
    – kubanczyk
    Jan 13, 2017 at 9:46
  • @kubanczyk: I minimally agree that the swap could become full without being a cause of worry, but it actually very rarely does if your memory is not overloaded, unless you use a form of zram or similar memory optimization tool. Jan 13, 2017 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.