问题
While loading .gapp files from disc using PersistenceManager.loadObjectFromFile I got the, "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space" Error. I increased the heap size to a maximum of 2048M and got the issue fixed. Is there a better alternative way to solve this issue when loading a large set of .gapp files.
回答1:
I think not, if you are using the default garbage collector. It needs the max heap size parameter for its work. Note that the memory is really needed. The error says that there was not enough memory for your gate applications (loaded gapp files).
There are two things you can do:
Find a lower value of max heap size parameter that is still working.
Reduce the amount of memory needed. For example by sharing some large objects (e.g. gazetteer lists) between gate applications. It can be done using
Factory.duplicate(Resource)
. See e.g. slides from Developers GATE Course .
来源:https://stackoverflow.com/questions/28807678/gate-persistencemanager-loadobjectfromfile-outofmemory-error-while-loading-gapp