dkunzler / esperandro

Easy SharedPreference Engine foR ANDROid
Other
180 stars 14 forks source link

Memory leak in ProcessingMessager #65

Closed Tapchicoma closed 4 years ago

Tapchicoma commented 4 years ago

Recently we start hitting quite constantly "GC overhead limit exceeded" error on building our application.

We managed to take heap dump of kotlin deamon process when this happens and, after analyzing it, we saw that ProcessingMessager consumes a lot of kotlin daemon heap memory.

Seems main issue that ProcessingMessager itself is singleton and holds a reference to JavacProcessingEnvironment here https://github.com/dkunzler/esperandro/blob/d88d8e7cee508a24af921190802412167dc2175e/base/src/main/java/de/devland/esperandro/base/processing/ProcessingMessager.java#L37. This prevents GC to remove a lot of portions of heap.

dkunzler commented 4 years ago

Hi, thank you for your analysis. Can you provide me with the heap dump you took? How large is it?

Tapchicoma commented 4 years ago

It is 8Gb in size. Will think how could it be provided.

dkunzler commented 4 years ago

ok, that's more than I expected. Perhaps we could use https://www.justbeamit.com/ for a P2P transfer.

Tapchicoma commented 4 years ago

@dkunzler contact me when you will be ready to receive file

dkunzler commented 4 years ago

@Tapchicoma I'm available now. You can send me the link via mail to not expose it to other people. dk@devland.de

dkunzler commented 4 years ago

Hi, I could analyze the heap you gave me, and in fact I can see that the processingEnv should not be retained as a static field here. I will start working on that asap.

dkunzler commented 4 years ago

Can you give a feedback if 3.0.2 works for you if you tried it? Thanks. @Tapchicoma

Tapchicoma commented 4 years ago

Sorry, we removed Esperandro from our repository and I don't have time to test it. If it still happens, somebody will open an issue again :slightly_smiling_face: