Menu

swapadd and freeing RAM

2023-02-12
2023-02-21
  • Danish Bronco

    Danish Bronco - 2023-02-12

    Hi again,

    I've tried to set a pagefile in a RAM disk using ImDisk, but I'm not completely satisfied with the result. However, maybe I just don't understand how it really works.

    After a few hours of use, the pagefile gets filled up to the limit I've set, and it doesn't seem to release any RAM, even after closing programmes.

    Is it an issue with Windows's memory management, is there a file system swapadd works best with, or is it just normal?

    It seems to me that if I just let Windows manage a pagefile on the SSD, its content and size would fluctuate, whereas when placed in a RAM disk, its size continuously increases, but never decreases.

    For example, I've set the in-RAM-disk pagefile with a minimum size of 16MB and a maximum size of 3072MB, yet the available space on my 6GB RAM disk shrinks rapidly, to the point that I get the infamous "Not enough space on P:\ - Some data will be lost" message.

    How can I address that?

     

    Last edit: Danish Bronco 2023-02-13
  • Danish Bronco

    Danish Bronco - 2023-02-13

    It just happened, and in all fairness, I had half a dozen tabs open in Firefox, four of them with YouTube videos caching and/or playing, but the "not enough space" message related to my other RAM disk (R:) where Temp and Firefox cache folders are stored, so I presume it's the combination of the activity on both RAM disks that caused the incident.

    Still, I think there's something wrong with the way a pagefile on a RAM disk is managed by Windows, or ImDisk, or both.

    Ideas, anyone?

     
  • Wizard

    Wizard - 2023-02-15

    Take a look at the powershell-command Enable-MMAgent. WIth it, you can enable just what you're manually trying to do here. A pagefile on a RamDIsk is no use since Windows is not aware of that fact to be able to make good use of it. Windows 10 and newer have the option for built-in PageFile-compression out of the box. You just have to enable it (on Servers, Clients have it enabled). You can see if it's active looking in Task Manager->Memory->In Use (Compressed). If there's a number between the brackets it is enabled. What actually happens with a pagefile is: You run low on memory or blocks of memory don't get actively used for a while->Write blocks to pagefile and remove from memory, thus freeing up available memory. What this new functionality does is: You run low on memory->Blocks that are shared between processes will be deduplicated in memory if possible->Blocks not active will be compressed and stay in memory->if memory-shortage continues beyond that, the "old" behavior kicks in and writes those compressed blocks to disk and removes them from memory. The critical new part is the functionality in the middle: try to "combine" shared blocks. This is the parameter -PageCombining. Compressing blocks in memory is parameter -MemoryCompression. If you do a Get-MMAgent you'll see both are enabled by default on a client and disabled on a server-version. In short, a pagefile on a Ramdisk doesn't do any good, in fact, it does worse, as you take away memory from Windows that it could use for this new functionality, resulting is less optimal behavior compared to not using a pagefile on a Ramdisk

     

    Last edit: Wizard 2023-02-15
  • Danish Bronco

    Danish Bronco - 2023-02-15

    I already had MMAgent enabled, but I see you point: Since a pagefile is supposed to be a resting place for data that was sitting in RAM, creating one in the RAM is akin to shooting yourself in the foot.

    However, I don't have a system disk pagefile by choice, even on a recent PC like my Asus that has a PCIe SSD, because I want to limit reads and writes as much as possible, so I thought creating a pagefile in the RAM disk would allow Windows (and some programs that just won't work or install properly in the absence of a pagefile) to find a place to copy their data.

    I suppose the file system can be a factor too: I chose FAT over the other file systems on both the RAM disk AND the pagefile, and sure enough, memory wasn't released, and my PC would run out of memory on the other RAM disk, where I only keep the Temp and Firefox cache folders. Probably has to do with the fact that Windows 11 prefers NTFS over any other file system.

    I'm not quite done testing yet, but as I write this reply, I'm doing without any pagefile at all, RAM-based or otherwise, and with just a FAT32 RAM disk for Temp and Firefox cache, my PC feels snippy enough.

    Thanks for your input, I'll keep you posted when I resume testing pagefile-on-RAM-disk. Cheers!

     
  • Danish Bronco

    Danish Bronco - 2023-02-21

    I finally got to the bottom of it... And it wasn't what I expected at all...

    It turns out the error message wasn't triggered by ImDisk, but by the fact that the disk cache in Firefox had a hard ceiling at 256 MB, was set on the RAM disk, and was easily maxed out when I had several YouTube tabs open at the same time.

    I changed a few settings in Firefox's cache management section in about:config, and everything's back to normal.

    • French shrug emoji *
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.