[erlang-questions] mmap file to binary

Angel Alvarez clist@REDACTED
Fri Apr 9 12:23:47 CEST 2010


Maybe a new alloc for mmaped files will allow manage diferences among OSes in a easy way...

http://www.erlang.org/doc/man/erts_alloc.html

It seems that the mmaped case is already covered using the  mseg_alloc:

mseg_alloc

A memory segment allocator. mseg_alloc is used by other allocators for allocating memory 
segments and is currently only available on systems that have the mmap system call. Memory 
segments that are deallocated are kept for a while in a segment cache before they are destroyed. 

When segments are allocated, cached segments are used if possible instead of creating new segments. 
This in order to reduce the number of system calls made.

Seem the code is in place, so cloning thw whole allocator and tweaking a bit the behaviour will suffice?


/Angel
El Viernes, 9 de Abril de 2010 11:11:25 Julian Tibble escribió:
> > Indeed, you are right. Just need to look, how to change free() to munmap()
> 
> That's also how it is done in the Sun Java VM, but it can cause a really
> annoying cross-platform problem [1].
> 
> The trouble is that on Windows a mapped file may not be deleted, but the
> point in time at which a file is unmapped with this scheme is
> non-deterministic because it relies on the garbage-collector. Thus,
> there is no reliable way to delete a file after it's been mapped.
> 
> Obviously on a Unix-like OS, there is no problem with unlinking a file
> that is in use, so everything works fine - but this can be even worse:
> things work fine on the developer's machine but when they distribute the
> software it breaks.
> 
> 
> Julian
> 
> [1]: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154
> 
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 
> 



-- 
Este correo no tiene dibujos. Las formas extrañas en la pantalla son letras.
__________________________________________

Clist UAH a.k.a Angel
__________________________________________
Vivimos en un sociedad exquisitamente dependiente de la ciencia y la tecnología, cuando muy poco gente conoce algo de la ciencia ó de la tecnología.


More information about the erlang-questions mailing list