@@ -216,6 +216,11 @@ static void GetConstrainedMemory(const FunctionCallbackInfo<Value>& args) {
216216 }
217217}
218218
219+ static void GetAvailableMemory (const FunctionCallbackInfo<Value>& args) {
220+ uint64_t value = uv_get_available_memory ();
221+ args.GetReturnValue ().Set (static_cast <double >(value));
222+ }
223+
219224void RawDebug (const FunctionCallbackInfo<Value>& args) {
220225 CHECK (args.Length () == 1 && args[0 ]->IsString () &&
221226 " must be called with a single string" );
@@ -633,6 +638,7 @@ static void CreatePerIsolateProperties(IsolateData* isolate_data,
633638 SetMethod (isolate, target, " umask" , Umask);
634639 SetMethod (isolate, target, " memoryUsage" , MemoryUsage);
635640 SetMethod (isolate, target, " constrainedMemory" , GetConstrainedMemory);
641+ SetMethod (isolate, target, " availableMemory" , GetAvailableMemory);
636642 SetMethod (isolate, target, " rss" , Rss);
637643 SetMethod (isolate, target, " cpuUsage" , CPUUsage);
638644 SetMethod (isolate, target, " resourceUsage" , ResourceUsage);
@@ -674,6 +680,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
674680 registry->Register (RawDebug);
675681 registry->Register (MemoryUsage);
676682 registry->Register (GetConstrainedMemory);
683+ registry->Register (GetAvailableMemory);
677684 registry->Register (Rss);
678685 registry->Register (CPUUsage);
679686 registry->Register (ResourceUsage);
0 commit comments