What are the problems that can occur over time, by allocating more memory to the java heap?

0

I have an application that is giving me Heap Space problems, looking at what I did with the profiler of netbeans and other apps, I realized that there are instances that are consuming almost a total of 2.2 GB of memory depending on the case is changing the total consumption and generating the typical error:

java.lang.OutOfMemoryError: Java heap space.

Well the first solution that occurred to me by obvious was to increase the memory of java, but before doing that I had to do something more important to look at the code of the application and see if it could be optimized, well the problem did not go through an optimization, there were instances that consumed a lot of memory and it is impossible to make it consume less memory in those instances.

For example: A case that was given was when you had to record a test case with more than 300 images this causes the error to fire.

Good after seeing the code analyzed and see why it consumed so much memory in some cases. it was concluded that the HEAP memory of java should be increased if or if.

After all this conclusion I need someone to tell me, what is the problem that can occur in the long term if I increase the memory of java.

since reading in several forums and blogs, they said that this is a temporary solution.

Why is it a temporary solution? How long will the application last with these changes if so?

The memory of the application was increased and tests were done to see how it behaved and works well. but I have the concern with the questions mentioned above.

Attentive to your comments and help.

    
asked by Ikabod 26.10.2017 в 23:37
source

1 answer

1

Depends on each case. For people who say it is a temporary solution it must be because they suffered from a memory leak, meaning that the GC could not release the memory properly and only increased the memory consumption, no matter how much memory was assigned to the application .

If in your case you know that, for example, with 4 GBs of memory your application will run without problems, then this would not be a temporary solution, it would be the solution. Of course, as long as your code does not have a memory leak and you have evaluated it appropriately.

    
answered by 30.10.2017 / 14:00
source