lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> That's not true.  On any modern desktop or server system, executables
> are demand-loaded.  Anything read-only and only touched once, like
> that const char[], is an good candidate for the OS to just drop, in
> the same way that it drops caches of files.  Files hang around in
> memory after you read them too...
> This does depend on a little on OS cache tuning.  Some kernels
> prioritize retaining mmap'd pages (like from executables) over
> retained caches of files.  But it's only a matter of degree.
> I suppose you could provide a stronger hint to the kernel by calling
> madvise, or munmap the data after you were done.  You'd have to be
> careful how you set up the latter of course.
> My first real C programming experiences were on the Amiga and MS-DOS
> where what you said is true.  I continue to find the physical memory
> usage on demand paged operating systems to be unintuitive.
> Jay

I completely agree, but as you said it depends on OS cache tuning or on
giving the right hints to the kernel while trying *not* to munmap your
code or data that is still needed. That's why I prefer to play safe and
read temporary data (i.e. Lua scripts) from the file system at the end
of an executable or as a file by itself. Compressing this data is only
an atempt to make the app distro smaller.

Andre de Leiradella