@@ -207,6 +207,13 @@ static void MemoryUsage(const FunctionCallbackInfo<Value>& args) {
207207 : static_cast <double >(array_buffer_allocator->total_mem_usage ());
208208}
209209
210+ static void GetConstrainedMemory (const FunctionCallbackInfo<Value>& args) {
211+ uint64_t value = uv_get_constrained_memory ();
212+ if (value != 0 ) {
213+ args.GetReturnValue ().Set (static_cast <double >(value));
214+ }
215+ }
216+
210217void RawDebug (const FunctionCallbackInfo<Value>& args) {
211218 CHECK (args.Length () == 1 && args[0 ]->IsString () &&
212219 " must be called with a single string" );
@@ -582,6 +589,7 @@ static void Initialize(Local<Object> target,
582589
583590 SetMethod (context, target, " umask" , Umask);
584591 SetMethod (context, target, " memoryUsage" , MemoryUsage);
592+ SetMethod (context, target, " constrainedMemory" , GetConstrainedMemory);
585593 SetMethod (context, target, " rss" , Rss);
586594 SetMethod (context, target, " cpuUsage" , CPUUsage);
587595 SetMethod (context, target, " resourceUsage" , ResourceUsage);
@@ -612,6 +620,7 @@ void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
612620 registry->Register (Umask);
613621 registry->Register (RawDebug);
614622 registry->Register (MemoryUsage);
623+ registry->Register (GetConstrainedMemory);
615624 registry->Register (Rss);
616625 registry->Register (CPUUsage);
617626 registry->Register (ResourceUsage);
0 commit comments