Java neo4j, REST and memory

后端 未结 3 964
余生分开走
余生分开走 2021-01-21 21:33

I\'ve deployed an app using neo4j java embedded version under Jersey tomcat for REST API. By measuring memory usage with jconsole I noticed each REST call adds 200Mb of memory (

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-21 22:10

    Java won't necessarily reclaim the memory as soon as it is available to be GCed. You might find that you're not seeing significant GC action until you get close to the heap limit. So even if you put your heap limit to 10gb, then you might find memory jumps up again. That isn't necessarily a problem.

    However, to solve the issue of neo using N x Memory, you should consider sharing the embedded instance between all your endpoints. Perhaps by moving it to a service class and having a shared instance between the endpoints. If you are using Spring with Jersey then this would be easy to do as you could wire it in by Spring.

提交回复
热议问题