WebKit enforces garbage collection / behavior and debugs / detects leaks

I am looking for memory leaks in this Cocoa / WebKit application. I pass objects from native to javascript, and looking at their life, I notice unpredictable behavior regarding garbage collection.

I mark each object with an incremental identifier and keep track of how many objects were created / released (garbage collected).

The first 1000 objects that were allocated are freed up pretty quickly after they are used, and # of the outstanding objects remains very low, around 10. Some random objects (like # 171) just never get freed.

After that, objects are delayed and not freed at all. This object # 171 is never going to be collected (after waiting for an hour to view the logs), but other objects with identical processing are deleted relatively quickly.

None of this proves that there are memory leaks, but it also does not confirm that they are not.

So, I have a couple of questions:

  • How to force FULL garbage collection in WebKit? I want to see if I have a memory leak. I tried JSGarbageCollect(globalContext), but it seems to have no effect. It does not release any objects that are later freed up, apparently by the GC.
  • Is it possible to indicate whether an object refers to it?
  • Are there any hooks in WebKit GC, for example, just to just know when they start, or to get some information / statistics?
  • - WebKit GC? ? , , .
+4

Source: https://habr.com/ru/post/1625012/


All Articles