Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java memory clean up

We have created the custom test-sutomation framework for our project. This mimics the interaction (mainly json two way data flow in GET and POST request) between browser and server using HTTP client.

Here is hot it happens, We have some 1000 test cases automated. Test case execution involves creation of tonnes of messages and hence tonnes of strings; reading large files repeatedly and verifying the contents and off-course throwing everything after getting verification result. It goes for all the test cases, takes anywhere between 15 to 20 hours.

The problem is that, we are stuck with OutOfMemory Error. Any Idea?; on cleaning up the memory which is consumed after reading and parsing from large files 100MB - 250MB. There are lot of splits, replace, substring operations going on.

Please, Can anybody provide tips,suggestions?

-Thanks in advance

like image 407
Akshay Sanganwar Avatar asked Aug 07 '26 04:08

Akshay Sanganwar


1 Answers

In general, you should make sure you maximize the objects available for garbage collection. One way to do this is declaring variables in the narrowest possible scope. (Eg: inside a try block, use method local variables)

You may also have to increase Java heap size.

like image 58
Amila Avatar answered Aug 09 '26 19:08

Amila



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!