OutOfMemoryError when saving resource [message #893704] |
Thu, 05 July 2012 10:22 |
Florin Missing name Messages: 6 Registered: November 2010 |
Junior Member |
|
|
Hi,
Sometimes, an OutOfMemoryError occurs when saving our emf model file. The model is zipped on saving and I suspect this might be the cause of the problems as I found some jdk bugs mentioning this problem (http:// bugs.sun.com/view_bug.do?bug_id=4797189). The model file is quite large, it can have even 50 MB uncompressed.
Calling System.gc(), System.runFinalization() before saving seamed to do the trick for a while, but the problem reappeared.
Has anyone encountered this problem? How did you solved it?
Would it be possible to re implement ResourceImpl.save, to not use ZipOutputStream/Deflater, but a third party zip library (which does not use native code, hence no issue)? Are there other solutions worth considering?
Any thoughts are welcomed.
Thank you,
Florin
|
|
|
Re: OutOfMemoryError when saving resource [message #893717 is a reply to message #893704] |
Thu, 05 July 2012 10:52 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Does XMLResource.OPTION_USE_FILE_BUFFER help? Or is this really some
type of low-level leak in the JVM? Adding dependencies for zip
alternatives doesn't sound very attractive...
On 05/07/2012 12:22 PM, Florin Mising name wrote:
> Hi,
>
> Sometimes, an OutOfMemoryError occurs when saving our emf model file.
> The model is zipped on saving and I suspect this might be the cause of
> the problems as I found some jdk bugs mentioning this problem (http://
> bugs.sun.com/view_bug.do?bug_id=4797189). The model file is quite
> large, it can have even 50 MB uncompressed.
> Calling System.gc(), System.runFinalization() before saving seamed to
> do the trick for a while, but the problem reappeared.
>
> Has anyone encountered this problem? How did you solved it?
> Would it be possible to re implement ResourceImpl.save, to not use
> ZipOutputStream/Deflater, but a third party zip library (which does
> not use native code, hence no issue)? Are there other solutions worth
> considering?
>
> Any thoughts are welcomed.
>
> Thank you,
> Florin
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Re: OutOfMemoryError when saving resource [message #893923 is a reply to message #893798] |
Fri, 06 July 2012 05:45 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Florin,
Yes, in both cases, these options avoid keeping data structures whose
size is proportional to the overall saved contents all in memory at once.
On 05/07/2012 4:11 PM, Florin Mising name wrote:
> It seams that using
> saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,
> Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
>
> sometimes caused an exception
> java.lang.OutOfMemoryError: Java heap space
> at java.util.Arrays.copyOf(Arrays.java:2786)
> at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.saveOnlyIfChangedWithMemoryBuffer(ResourceImpl.java:1151)
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:980)
>
>
> Using
> saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,
> Resource.OPTION_SAVE_ONLY_IF_CHANGED_FILE_BUFFER);
>
> fixes the issue.
>
> Best regards,
> Florin
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03685 seconds