what's the difference between IdleNotification and LowMemoryNotification?

147 views
Skip to first unread message

kunjie Chen

unread,
Apr 22, 2015, 10:14:46 PM4/22/15
to v8-u...@googlegroups.com

I'm using the v8 in a multi-thread env, runing normal scripts in one thread and doing the garbage collection in another.
and I found IdleNotification(int idle_time_in_ms)  and LowMemoryNotification() api to do tht gc work.
I test this two api in my program and find out LowMemoryNotification seems really do the gc work, 
but the IdleNotification does not.

So, what's the difference between this two api? 
Are those two apis doing the same kind of garbage collection ?

Louis Santillan

unread,
Apr 22, 2015, 11:02:53 PM4/22/15
to v8-u...@googlegroups.com
In past v8s, you could write something like

IdleNotification()

to do one pass of GC (an incremental pass in event loop or another
idle moment in your app), or,

while( IdleNotification() );

to do a full sweep & collection. IdleNotification() returns false
when there is no work to be done by the GC. LowMemoryNotification()
is a more direct way of performing the second technique. It tells the
GC to make some memory available.
> --
> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jakob Kummerow

unread,
Apr 23, 2015, 4:07:45 AM4/23/15
to v8-u...@googlegroups.com
On Thu, Apr 23, 2015 at 4:14 AM, kunjie Chen <kjche...@gmail.com> wrote:

I'm using the v8 in a multi-thread env, runing normal scripts in one thread and doing the garbage collection in another.

Knowing how the garbage collector works, there's no way this can work.

kunjie Chen

unread,
Apr 23, 2015, 4:09:26 AM4/23/15
to v8-u...@googlegroups.com
Thanks for the answer.
So, the IdleNotification api do the complete gc,
And the LowMemoryNotification just free some space, there can be gc work after calling LowMemoryNotification.


在 2015年4月23日星期四 UTC+8上午11:02:53,Louis P. Santillan写道:

Jochen Eisinger

unread,
Apr 23, 2015, 4:10:48 AM4/23/15
to v8-u...@googlegroups.com
Unless you use v8::Lockers to make sure only one thread at a time actually does any work.

Anyway, LowMemoryNotification forces up to 7 compacting GCs. While IdleNotificationDeadline (the IdleNotification version is deprecated and will go away soon) tries to do some garbage collection work that fits between now and the deadline. If you feed V8 enough idle time via this API, you should see almost no GC activity during script execution.

best
-jochen

--
Message has been deleted

kunjie Chen

unread,
Apr 23, 2015, 4:16:05 AM4/23/15
to v8-u...@googlegroups.com
Yes, I did use the v8::Locker to call LowMemoryNotification In another thread.

在 2015年4月23日星期四 UTC+8下午4:10:48,Jochen Eisinger写道:
Reply all
Reply to author
Forward
0 new messages