Ejemplo n.º 1
0
///TESTER FUNCTIONS
//TODO: Expose the old_space_ expansion function and test how it works
void GetHeapSize(const v8::FunctionCallbackInfo<v8::Value>& args){
  
  Local<ObjectTemplate> result = ObjectTemplate::New(args.GetIsolate());
  
  HeapStatistics hs;
  args.GetIsolate()->GetHeapStatistics(&hs);
  unsigned sz = hs.total_heap_size();
  /*
  v8::internal::Heap * heap = reinterpret_cast<v8::internal::Isolate*>(args.GetIsolate())->heap();
  unsigned u = heap->old_space()->Capacity();
*/
  args.GetReturnValue().Set(v8::Integer::NewFromUnsigned(args.GetIsolate(), sz));
}
Ejemplo n.º 2
0
Handle<Value> js_used_heap(Local<String> property,
                           const AccessorInfo& info) {
    LOGFN("used_heap");

    HandleScope handle_scope;
    HeapStatistics stats;

    V8::GetHeapStatistics(&stats);

    int used_heap = (int)stats.used_heap_size();

    LOGFN("end used_heap");
    return handle_scope.Close(Number::New(used_heap));
}
Ejemplo n.º 3
0
void afterGC(GCType type, GCCallbackFlags flags) {
	unsigned long long gcRealEnd;
	
	// GC pause time
	if (plugin::timingOK) {
		plugin::timingOK = GetSteadyTime(&plugin::gcSteadyEnd);	
	}
	const uint64 gcDuration = plugin::timingOK ? CalculateDuration(plugin::gcSteadyStart, plugin::gcSteadyEnd) : 0; 

	// Get "real" time
	gcRealEnd = GetRealTime();

	// GC type
	const char *gcType = (type == kGCTypeMarkSweepCompact) ? "M" : "S";

	// GC heap stats
	HeapStatistics hs;

	Nan::GetHeapStatistics(&hs);

	std::stringstream contentss;
	contentss << "NodeGCData";
	contentss << "," << gcRealEnd; 
	contentss << "," << gcType;
	contentss << "," << hs.total_heap_size();
	contentss << "," << hs.used_heap_size();
	contentss << "," << gcDuration;
	contentss << '\n';
	
	std::string content = contentss.str();

	// Send data
	monitordata data;
	data.persistent = false;
	data.provID = plugin::provid;
	data.sourceID = 0;
	data.size = static_cast<uint32>(content.length());
	data.data = content.c_str();
	plugin::api.agentPushData(&data);
}
Ejemplo n.º 4
0
void JsEngine::DumpHeapStats() 
{
	Locker locker(isolate_);
    	Isolate::Scope isolate_scope(isolate_);

	// gc first.
	while(!V8::IdleNotification()) {};
	
	HeapStatistics stats;
	isolate_->GetHeapStatistics(&stats);
	std::wcout << "Heap size limit " << (stats.heap_size_limit() / Mega) << std::endl;
	std::wcout << "Total heap size " << (stats.total_heap_size() / Mega) << std::endl;
	std::wcout << "Heap size executable " << (stats.total_heap_size_executable() / Mega) << std::endl;
	std::wcout << "Total physical size " << (stats.total_physical_size() / Mega) << std::endl;
	std::wcout << "Used heap size " << (stats.used_heap_size() / Mega) << std::endl;
}