memory mapped i/o?

Jeff Sturm jsturm@detroit.appnet.com
Mon Dec 4 14:02:00 GMT 2000


David Brownell wrote:
> Just curious ... has anyone done work to make GCJ work well
> with memory mapped files?  It seems to me that would call for
> some smart hookups to the garbage collector, but it shouldn't
> be that hard unless there are assumptions being made about
> ability to relocate data.  (Speaks someone who's rarely had
> to look at that level of a JVM ... ;-)

The GC will ignore memory regions outside the heap, including mmap'ed
regions.  Such regions must not contain pointers to live objects, unless
care is taken that those objects are also reachable from some root. 
Otherwise there is no problem with GC.

> I could see a variety of applications (webpage serving and
> some video apps come to mind :-) benefitting from such stuff.
> (But so far as I know, Sun's JCP hasn't looked at this.)

The problem as I see it is that the memory region must be copied to/from
a Java array to be useful.  This copy defeats the advantages of memory
mapping somewhat.  It would be convenient to create primitive arrays
directly mapped to a file, but gcj cannot easily do this because the
array requires an object header.

Jeff


More information about the Java mailing list