Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 12647002: Fix memory leaks in libadblockplus (Closed)

Created:
Oct. 6, 2013, 10:21 p.m. by Oleksandr
Modified:
Oct. 15, 2013, 6:32 a.m.
Visibility:
Public.

Description

I have found 2 memory leaks. 1. Persistent handles were not being disposed (unlike the Local ones, they have to be disposed manually) 2. The garbage collection did not seem to be running. The Matches() calls produce the most garbage. I have put the GC in the GetElementHidingSelectors though, since that runs only once per page, and we don't want to be overly enthusiastic with the cleanups. With these changes the memory usage stays more or less the same for me.

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+9 lines, -1 line) Patch
M include/AdblockPlus/V8ValueHolder.h View 1 chunk +8 lines, -1 line 1 comment Download
M src/FilterEngine.cpp View 1 chunk +1 line, -0 lines 2 comments Download

Messages

Total messages: 3
Oleksandr
Oct. 8, 2013, 7:51 a.m. (2013-10-08 07:51:54 UTC) #1
Wladimir Palant
LGTM on fixing V8ValueHolder if you avoid code duplication as outlined below. Triggering garbage collection ...
Oct. 8, 2013, 8:12 a.m. (2013-10-08 08:12:19 UTC) #2
Felix Dahlke
Oct. 10, 2013, 8:36 a.m. (2013-10-10 08:36:26 UTC) #3
LGTM with Wladimir's issue addressed.

http://codereview.adblockplus.org/12647002/diff/1/src/FilterEngine.cpp
File src/FilterEngine.cpp (right):

http://codereview.adblockplus.org/12647002/diff/1/src/FilterEngine.cpp#newcod...
src/FilterEngine.cpp:236: jsEngine->Gc();
On 2013/10/08 08:12:19, Wladimir Palant wrote:
> This is a really bad idea, it will cause unnecessary delays. Embedders are
only
> supposed to call V8::IdleNotification() when they are actually idle.
> 
> As it is now, the Gc() method is only useful for testing. We can turn it into
a
> proper wrapper for V8::IdleNotification() - only calling
V8::IdleNotification()
> once and returning its return value, but with an additional lock to make sure
no
> JS code is running. However, we would actually need to call that in the
> application using libadblockplus (in the message loop or its equivalent)
because
> otherwise we cannot know when that application is idle. Not quite easy but
worth
> looking into.

I don't think we should look into this at this point. High memory usage is what
we get for using garbage collection to begin with, it's an issue we have on each
and every platform. The only real way to fix this is to put energy into avoiding
GC in the core code, which is what ChimeraScript would address.

I doubt that, once we have that, using v8::IdleNotification properly will gain
us much.

Powered by Google App Engine
This is Rietveld