`ObjectMapper` default heap consumption increased significantly from 2.13.x to 2.14.0
See original GitHub issueHello,
I’m currently looking at heap consumption when using native image with a Spring Boot 3 application. Spring Boot 3.0 SNAPSHOT uses Jackson 2.14.0-rc3. I noticed that with the upgrade from 2.13.4.2 to 2.14.0 the application uses more heap memory, which i tracked down to this PR. It changed the cache implementation from ConcurrentHashMap
to PrivateMaxEntriesMap
, which in turn preallocates a lot of AtomicReference
(they appear to be all empty).
I created a reproducer here - it creates an empty objectmapper and then dumps the heap. It has more information and screenshots in the README.
When using Jackson 2.13.4.2 it uses 567 B for the LRUmap, with Jackson 2.14.0 it uses 507320 B for the LRU map. The bad thing is that most of these caches are per ObjectMapper
- create more of them and it uses even more heap.
As we’re trying to optimize the memory consumption of native image applications, this is quite a bummer and we hope you can help us out here.
Thanks!
Issue Analytics
- State:
- Created 10 months ago
- Reactions:3
- Comments:46 (24 by maintainers)
Top GitHub Comments
Ta-dah! I did it. 2.14.1 release mostly done, last couple of artifacts on their way to Maven Central (Scala module may take bit longer). Please LMK if you find issues.
@pjfanning you forgot to account for the
AtomicReference
instances themselves. That ranges from 16-32 bytes depending on the jvm optimizations (compressed references, compressed class pointers, byte alignment). In that case you might expect to see it as16 * 128 (4 + 32) = 73,728
or ~300kb if each mapper uses 4 caches. Using Java Object Layout,