Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>What is the best way to determine how much memory to allocate?</p> </blockquote> <p>Due to how virtual memory is used, non-swappable kernel memory, it is nearly impossible to identify how much of installed memory can be accessed by an application.</p> <p>Best I can come up with is to allow user to configure how much memory to use for buffering.</p> <blockquote> <p>Am I limited to just allocating a slightly smaller block than the reported free memory, </p> </blockquote> <p>Reported free memory is not really "free physical memory." Unfortunately.</p> <blockquote> <p>or can I interface more directly with the linux virtual memory manager?</p> </blockquote> <p>That can be done by using a custom device driver, allocating memory directly in kernel space and providing access to it via <code>mmap()</code>. Generally not recommended, yet would works in specialized cases such as yours.</p> <blockquote> <p>However, I also need to make sure that there will be no disk-swapping</p> </blockquote> <p>At pace of the Linux kernel development, knowledge becomes obsolete quite fast, so take with grain of salt what I'm saying here. You can try to play with the following:</p> <ol> <li><p>SysV shared memory. It is generally not swapped. See <code>man shmget</code>.</p></li> <li><p>tmpfs - in-memory file system. The memory was pinned to RAM at least in early 2.6 kernels and thus was not swappable. To use it as memory, create a file on tmpfs, <code>write()</code> something into the file (to force the memory being actually allocated) and then mmap() the file.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload