How to pre-allocate memory for RAMFS volume
2 posts
Is it possible to pre-allocate memory for RAMFS volumes? I have an issue where the disk shows available space, but I am getting an out of space error when trying to write a file. My system RAM usage is high and I guess it is using memory that RAMFS is expecting to be available.
Your guess is correct. A RAM FS volume is thin: it takes memory only as data is written, so its free space is a ceiling, not memory set aside for it. When other processes have used up the RAM, writes fail even though the volume still shows room. RAM FS has no option to reserve memory upfront.
Our RAM Disk can do that: with Dynamic memory allocation unticked, a disk takes its full size in RAM when mounted and keeps it. There still may be some issues, though. When memory runs short, the disk keeps working, but whatever else is using up the memory fails instead. Usually it is better to make the volume smaller or leave more RAM free, so that everything fits at once.