简体   繁体   中英

SWT application : Java heap space: java.lang.OutOfMemory

I have a SWT application which accepts the java type project and do some parsing mechanism on all the file, it was working fine but in large project which have a huge count of file it starts generating error:

Java heap space: java.lang.OutOfMemory

and terminate the parsing. how could i handle it by java programming, by not having guess about the user's machine configuration.

Note: Till now i tried a mechanism that i count the project file first if it across the MAX size which i take 1000 here, divided project in the chunk of folders containing 50 file and parse them one by one but it also not clicked and i got the error after some folder's parsing.

The most realistic approach (since you did not share any piece of code) when having Java heap space: java.lang.OutOfMemory would be to profile your Java application so that you can have more accurate idea where your application is running out of heap space. Then you can modify your code to reduce the memory usage of your application.

YourKit and VisualVM are two good examples of Java profiling software that you can use to test your application.

Furthermore increasing the heap size of the project can be considered as a possible solution. You simply need to re-adjust -Xmx option of virtual machine which sets the maximum size of the heap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM