Ask the Expert

  • 1.  MX5 Cashe Memory

    Posted 12-16-2020 19:08

    Hello experts ,


    Is it normal to have this high amount of cache memory (460M) > MX5


    Mem: 1150M Active, 110M Inact, 186M Wired, 460M Cache, 112M Buf, 76M Free
    Swap: 2821M Total, 2821M Free

    Any way to clear this cache and free up some memory ?

    Thanks



    ------------------------------
    emre gonzalez
    ------------------------------


  • 2.  RE: MX5 Cashe Memory

    Posted 12-17-2020 10:03

    Yes, this is expected behaviour, system will free up this memory when any application will need additional memory



    ------------------------------
    Anatoliy
    ------------------------------



  • 3.  RE: MX5 Cashe Memory
    Best Answer

     
    Posted 12-19-2020 16:56

    This is related to how memory management running in Junos/FreeBSD as it's a little bit tricky

    - Unix systems manage the memory resource more intelligently. They never let the RAM go to waste. Whenever you have a memory that is not used by applications, Unix systems will use it to cache or buffer things that they might need to have fast access to, like caching disk or frequently used application data. However, that part of the memory that is cached and buffered is just like it's free.
    - So it doesn't matter to the Unix system if the memory was empty or filled with cached or buffered data, because when an application needs it, that memory is viewed as free by the system to be used by the application immediately.


    Generally, the kernel is lazy about migrating memory out of the Inactive queue into the cache or freelist unless there is a memory shortage.
    This can lead to large discrepancies between the values reported by RPD and the kernel, especially after RPD has freed a large amount of memory like deleting a bunch of routes.

    Please note that the pageout daemon runs only when the router is under memory pressure. Since memory was not under pressure at that time, the pageout daemon was not running. Therefore, the pages on the inactive list would remain there.

    From the kernel's perspective, "Active", "Inactive" and "Wired" pages are all in-use pages.
    The distinction between "Active" and "Inactive" is just the relative priority for the pageout daemon to "steal" pages from them when there is memory pressure. The pageout daemon steals from the "Inactive" list first, and then from the "Active" list if necessary to alleviate memory pressure.

    Pages reported as "Cache" and "Free" in "show system processes" are what the kernel considers as truly free. "Cache" pages are free pages that still have known page contents.

    Since the kernel never clears the Inact memory periodically, so one may see the Inact/cache memory stays there for a very long time.
    This behaviour of the kernel is trying to maximize the use of memory cache and minimize the I/O access. That's the reason why one sees Inact memory stays there for a very long time.
    The short answer is the kernel will reclaim/reuse freed memory when there is memory pressure.

    Regards,