I added an API for this in V8 bleeding_edge revision 3089.

For reference, here is the test code using the API:

THREADED_TEST(GetHeapStatistics) {
  v8::HandleScope scope;
  LocalContext c1;
  v8::HeapStatistics heap_statistics;
  CHECK_EQ(heap_statistics.total_heap_size(), 0);
  CHECK_EQ(heap_statistics.used_heap_size(), 0);
  v8::V8::GetHeapStatistics(&heap_statistics);
  CHECK_NE(heap_statistics.total_heap_size(), 0);
  CHECK_NE(heap_statistics.used_heap_size(), 0);
}

-- Mads

On Thu, Oct 8, 2009 at 12:48 AM, [email protected]
<[email protected]> wrote:
>
> Hi,
>
> I'd like to query the amount of memory allocated from the OS for the
> V8 heap as well as the amount of bytes occupied by allocated objects
> within the heap.  Currently, there is a heap profiler API but it seems
> much too heavyweight for this use case and I would be wary of leaving
> it on all the time.  It is also possible to call V8::SetCounterFunction
> () and then sniff for updates to the "c:V8.OsMemoryAllocated" and
> related counters, but this seems very brittle.  I am not aware of any
> other ways to get this information directly and I would propose an API
> that looked something like this be added to class V8:
>
> static void GetHeapStatistics(size_t* os_memory_allocated, size_t*
> memory_in_use);
>
> My use case is that in Chromium's task manager it would be nice to
> know how much of the memory footprint of a given renderer process is
> due to V8's heap.  Fields within the task manager are populated by
> polling each process at about 1Hz.
>
> Does this sound reasonable?
>
> - James
> >
>

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to