0

I'm building up a three tier application :

1 - Incoming requests are received withing the first tier

2 - Second tier is realising the business logic and parsing domain object to DTOs using model mapper.

3 - Third tier is realising all the CRUD operations

On the third tier, i'm using an entity manager to perform my CRUD Operations and creating one in each of my method without closing it.

Could the fact of not closing my entity manager after each request and creating one in each method be related to my out of memory error when performing a large amount of requests ?

Thanks in advance

daley
  • 177
  • 1
  • 2
  • 9

1 Answers1

0

There could be various reasons for getting OOM; most of the time due to problem similar to you have mentioned in your question.

Have you tried closing the entity manager and then verify if you are getting OOM exception or not?

Closing Entity Manager depends upon how you have your transactions handled. If you are creating the EM programmatically, then you would need to take care of closing. If it is something handled by persistence context, then you would not need to.

Here is informative question/answer related to Entity Manager. Should JPA Entity Manager be closed?

Additionally, you could use some memory analyzer tool to see heap dump.

Community
  • 1
  • 1
Mihir
  • 270
  • 3
  • 9
  • Thank you for these answers. I'll try this out and monitor to see if it makes a great difference, most of the things i've read so far is that I need to increase my heap size etc... might give a shot to that but I need my work to be as clean as possible. – daley Aug 04 '15 at 20:35