• Peter Marshall's avatar
    [cpu-profiler] Clear the CodeMap after the last profile to stop leak · 73a94290
    Peter Marshall authored
    We kept the CodeMap filled with entries between profiles, even in
    kLazyLogging mode which will re-fill the CodeMap when profiling starts
    again. See the bug for more details.
    
    This fix manually clears the CodeMap after the last profile is deleted.
    We already call DisableLogging() when the last profile is stopped. At
    this point we still need the CodeMap alive because the profile object
    we expose via the API is backed by the CodeEntry objects in the CodeMap.
    Once the last profile is deleted though, we can empty the CodeMap.
    
    There is still another bug, which is that we never delete CodeEntry
    objects for deleted code, as there are no CodeDeleteEvents from the GC.
    We will work on that separately, but this fix should stop those leaks
    accumulating between profiles as we wipe the CodeMap entirely between
    profiles (at least for kLazyLogging mode). kEagerLogging mode still has
    this problem and will only be fixed by introducing CodeDelete events or
    similar.
    
    Bug: v8:11051
    Change-Id: Iab9570747d17c657e6e318d434f935af8047d05f
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2491033
    Commit-Queue: Peter Marshall <petermarshall@chromium.org>
    Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#70792}
    73a94290
test-profile-generator.cc 31.4 KB