Am I supposed to call EntityManager.clear() often to avoid memory leaks?

后端 未结 3 1192
滥情空心
滥情空心 2021-01-12 03:39

I\'m new to JPA/OpenJPA and I noticed that if I don\'t call EntityManager.clear() after i persist entities I get an OutOfMemoryError (I keep adding

3条回答
  •  情书的邮戳
    2021-01-12 04:32

    Depends how many objects you bring into the persistence process (read). If you handle large numbers (or some of the objects are large) then use of clear() can make sense. Each time an object is read it should be put in the L1 cache by the JPA impl.

提交回复
热议问题