Hi,

Sorry for the delay.

I've run that code in the two test machines we have (one 32 bits and
one 64 bits). This problem only happened in the 32 bit machine, and it
also happened in that little test. On the 32 bits machine it ends
with:

length: 1073741824
length: 2147483648
Exception in thread "main" java.io.IOException: Map failed
        at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:758)
        at
org.h2.store.fs.FileObjectDiskMapped.reMap(FileObjectDiskMapped.java:
102)
        at
org.h2.store.fs.FileObjectDiskMapped.setFileLength(FileObjectDiskMapped.java:
164)
        at
org.h2.store.fs.FileObjectSplit.setFileLength(FileObjectSplit.java:
113)
        at
outsystems.hubedition.logservice.LogQueueBulkHandler.main(LogQueueBulkHandler.java:
796)
Caused by: java.lang.OutOfMemoryError: Map failed
        at sun.nio.ch.FileChannelImpl.map0(Native Method)
        at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:755)
        ... 4 more

And in the 64 bits machine it finishes without problem with length
17179869184. I don't know how difficult it would be to map only part
of the file in memory instead of the whole file, but I think that's a
better solution than falling back to nio (However, it would also solve
our problem).

Regards.

On Aug 27, 12:53 pm, Thomas Mueller <[email protected]>
wrote:
> Hi,
>
> I think what should to be done is catch the out of memory error and
> then automatically fall back to regular io (non-mapped).
>
> Regards,
> Thomas
>
> On Fri, Aug 27, 2010 at 1:09 PM, Thomas Mueller
>
>
>
>
>
>
>
> <[email protected]> wrote:
> > Hi,
>
> > If you get an out of memory exception then something is wrong... Of
> > course it's possible to re-try, but I think the out of memory problem
> > is serious and needs to be solved. What happens if you run this?:
>
> > String fileName = "split:nioMapped:~/data/h2database/h2/data/test";
> > FileSystem m = FileSystem.getInstance(fileName);
> > m.createNewFile("split:nioMapped:data/test");
> > for (long l = 16; l <= 16L * 1024 * 1024 * 1024; l+= l) {
> >    FileObject fo = m.openFileObject(fileName, "rw");
> >    System.out.println("length: " + l);
> >    fo.setFileLength(l);
> >    fo.close();
> > }
>
> > Maybe we need to use some other strategy and not map the complete file
> > in memory...
>
> > Regards,
> > Thomas

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to