1

I am getting error "java.lang.OutOfMemoryError: GC overhead limit exceeded" while deleting 500 object in loop(in one Transaction only). I had also verified my code and making sure that all the objects are getting dereferenced. I had also tried to increased the heap size then also it's giving me an same error. So to find out which object is consuming more memory, i had used "JProfiler" and "visualvm", both the tools gave me same result; "ChangeObjectSet" which is class of eclipse link(2.5.2) consuming more memory, also tried with newer version of eclipse link still getting the same error.

Stacktrace:

Stacktrace

Thank you in advance for any help you can provide.

Nithin
  • 1,376
  • 12
  • 29
Bhavik Patel
  • 119
  • 4
  • 1
    Have you done any memory profiling? Without it, we can only speculate. – Joe C Sep 29 '17 at 05:51
  • 1
    nice thing to know about the gc ... just because you expect or want it to run, doesn't mean it will actually run. It' ll run when the VM decides to, not earlier. – Stultuske Sep 29 '17 at 05:58
  • You are running out of memory. Plain and simple. Find out where your leak is. – Thorbjørn Ravn Andersen Sep 29 '17 at 06:27
  • @ThorbjørnRavnAndersen I found that leak is because of the object of "ChangeObjectSet" which is and class of eclipselink. – Bhavik Patel Sep 29 '17 at 06:56
  • Are you using JPA properly then? – Thorbjørn Ravn Andersen Sep 29 '17 at 07:15
  • More details of what you are doing are required. Does memory steadily increase, like when there is a memory leak, or is it just with this one operation? How much memory is required when you just read in these 500 objects? How much memory have you allocated compared to what this process should reasonably be expected to use? Also note - the ChangeObjectSet is just a map used to track the changes you've made in your transaction, a requirement of JPA, not a leak unless it never clears. – Chris Sep 29 '17 at 14:08
  • @Chris I had implemented Rest API to delete 1 object and calling that API in loop. Memory is not steadily increase, it's just with this one operation only. Generally it required around 500mb-1gb but for this process i have assigned 3gb. – Bhavik Patel Sep 30 '17 at 04:28
  • I don't follow - A unitOfWork and related objects are tied to EntityManager instances. If they are building up, you are likely holding onto EntityManagers and the related object and it isn't a 1 shot call being done in a loop. Show your code, as the problem is likely in your application – Chris Sep 30 '17 at 16:29

1 Answers1

0

The Eclipse IDE's basic memory allocation is good only for small Projects, when you load a huge project in an Eclipse IDE (that consists of huge data), Eclipse runs out of Memory and hence you get the error.

Here is a link which had worked out for me... Try it.