1

I've read this What might be the cause of "long monitor contention event with owner method"?

It says I should be looking where lock is asked. So, it's LazyJVM.kt:69 of kotlin stdlib.

It's likely used when using lazy delegate. So, I removed wherever I used it to figure out what actually causing it, but I'm still getting this warning. So, there might be other libs using lazy, or not.

Is there any way to trace which call caused it, Or is there something I'm missing?

Update: I was actually able to find the cause by Stacktrace I missed one lazy init the object was asked by multiple function calls and since it's lazy delegates are evaluated exactly once the other callers are all locked for the evaluation to finish.

To reproduce this have a lazy singleton object that takes some time to init (maybe add artificial delay) then call the object almost at the same time from different functions.

Cyber Avater
  • 1,494
  • 2
  • 9
  • 25

1 Answers1

0

See How to make Java Thread Dump in Android? to get a thread dump. Once you have the entire stack of the calls to the lazy delegate, you should be able to see what code is causing the problem.

You'll need to capture the stack just before the warning message appears.

Raman
  • 17,606
  • 5
  • 95
  • 112