Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » OutOfMemoryError when saving resource
OutOfMemoryError when saving resource [message #893704] Thu, 05 July 2012 10:22 Go to next message
Florin Missing name is currently offline Florin Missing nameFriend
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 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
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 #893729 is a reply to message #893717] Thu, 05 July 2012 11:28 Go to previous messageGo to next message
Florin Missing name is currently offline Florin Missing nameFriend
Messages: 6
Registered: November 2010
Junior Member
Looks promising. I will try it.

Thank you,
Florin
Re: OutOfMemoryError when saving resource [message #893798 is a reply to message #893729] Thu, 05 July 2012 14:11 Go to previous messageGo to next message
Florin Missing name is currently offline Florin Missing nameFriend
Messages: 6
Registered: November 2010
Junior Member
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

Re: OutOfMemoryError when saving resource [message #893923 is a reply to message #893798] Fri, 06 July 2012 05:45 Go to previous message
Ed Merks is currently offline Ed MerksFriend
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/
Previous Topic:[emf] don't use other edit plug-ins as delegated resource locators
Next Topic:[CDO] CDO Workspace. On commit 'Change set is outdated'
Goto Forum:
  


Current Time: Tue Apr 23 11:29:06 GMT 2024

Powered by FUDForum. Page generated in 0.03685 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top