2 things come to mind: 1. Are you sure that the JS code is not leaking i.e. retaining objects generated each time you call it? 2. After returning from the JS call, did you exit the HandleScope that was used for that call? If not, maybe your handle scope is holding on to some unused object.
On Aug 4, 8:32 am, Bryan White <[email protected]> wrote: > I have an app where in I call a function in Javascript repeatedly. > When doing this the app gradually consumes memory. It seems if the > app keeps running there is no limit to the amount of memory that will > eventually be consumed. I have tried tinkering with forcing garbage > collection to no great affect. I checked out a fresh copy of trunk > this morning (Revision: 5173) > > After each call I am doing this: > > static int cycle = 0; > ++cycle; > if(!(cycle % 10000)) > { > int precount = V8HashCount; > while(!V8::IdleNotification()) ; > V8::LowMemoryNotification(); > HeapStatistics hs; > V8::GetHeapStatistics(&hs); > TRACE("Internal GC V8HashCount:%d-->%d v8heap:%.2f/%.2f > MB",precount, V8HashCount,hs.used_heap_size() / 1024.0 / 1024.0 > ,hs.total_heap_size() / 1024.0 / 1024.0); > } > > And at the end: > > int precount = V8HashCount; > V8::ContextDisposedNotification(); > V8::LowMemoryNotification(); > while(!V8::IdleNotification()) ; > V8::LowMemoryNotification(); > HeapStatistics hs; > V8::GetHeapStatistics(&hs); > TRACE("Final GC V8HashCount:%d-->%d v8heap:%.2f/%.2f MB",precount, > V8HashCount,hs.used_heap_size() / 1024.0 / 1024.0 > ,hs.total_heap_size() / 1024.0 / 1024.0); > > FYI: V8HashCount is a count of objects passed into V8 with a weak > handle that have not yet been destroyed. > > Here is the output I get for a run of 100K iterations. > 8/4/2010 10:57:04 Internal GC V8HashCount:2575-->6 v8heap:10.43/11.65 MB > 8/4/2010 10:57:26 Internal GC V8HashCount:6953-->6 v8heap:19.67/21.00 MB > 8/4/2010 10:57:49 Internal GC V8HashCount:4337-->6 v8heap:28.90/30.22 MB > 8/4/2010 10:58:12 Internal GC V8HashCount:449-->6 v8heap:38.13/39.32 MB > 8/4/2010 10:58:36 Internal GC V8HashCount:4170-->6 v8heap:47.36/48.66 MB > 8/4/2010 10:58:59 Internal GC V8HashCount:18989-->6 v8heap:56.59/57.88 MB > 8/4/2010 10:59:24 Internal GC V8HashCount:4063-->6 v8heap:65.82/67.22 MB > 8/4/2010 10:59:48 Internal GC V8HashCount:9617-->6 v8heap:75.06/76.33 MB > 8/4/2010 11:00:14 Internal GC V8HashCount:30125-->6 v8heap:84.29/85.55 MB > 8/4/2010 11:00:39 Internal GC V8HashCount:20922-->6 v8heap:93.52/94.89 MB > 8/4/2010 11:00:42 Final GC V8HashCount:18-->0 v8heap:93.16/94.56 MB > > It seems like garbage collection is working but memory is still leaking. > > I need to address this because in production this code will be > expected to run continuously and handle around 4 million cycles per > day. > -- > Bryan White -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
