To a write a leak regression test for js shell currently one can either try to use rather unreliable performance degradation characteristics of the leak or use the countHeap function tp observe the heap growth or that GC cannot collect some things. Unfortunately with the consevative GC it is not easy to use countHeap reliably as it is hard to estimate the number of GC things reachable through the stack and registers. So as an alternative to the countHeap I suggest to have a special purpose object that during the finalization would increase some global counter and expose that counter in the shell. Then one can observe the leak via storing this the special object in the structure that should be GC-ed and comparing the counter before and after the GC. A conservative GC can still spoil this picture but I have found that by running the corresponding test code twice one can reliably make sure that the native stack and registers do not contain references to GC things from the first run.
Created attachment 476730 [details] [diff] [review] v1 The patch adds two functions to js shell. makeFinalizeObserver() creates the object which finalization increases the counter and finalizeCount() returns the counter.
Attachment #476730 - Flags: review?(jorendorff)
Comment on attachment 476730 [details] [diff] [review] v1 Good idea. >+" get a special object which finalization increases the counter returned\n" "which" should be "whose" here.
Attachment #476730 - Flags: review?(jorendorff) → review+
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.