title: how many v8 isolates can I create?
body: <p>I need to have thousand of isolates within V8.
  But I have encountered weird problem with memory, when I have some amount of free RAM, but v8 throws OOM error messages.</p>
  
  <p>For example,</p>
  
  <p><a href="https://i.stack.imgur.com/Jsggq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jsggq.png" alt="enter image description here"></a></p>
  
  <p>In this particular case, you can see we still have some RAM when V8 throws this error. Number 2047 - iterator number. So basically code looks like:</p>
  
  <pre><code>for(int i = 0; i &lt; 3000; i++) {
     std::cout &lt;&lt; i &lt;&lt; std::endl;
     new Isolate(params);
  }
  </code></pre>
  
  <p>Maybe I need to increase stack size limit. I have set it already to 16Mb. And still have this problem.
  htop shows just 4 threads for this process. So I don't think that the problem with threads.</p>
  
  <p>Inside v8 class I do</p>
  
  <pre><code>  this-&gt;_maxRAMAvailable = 8; // 8Gb in my case
    int maxOldSpaceMb = this-&gt;_maxRAMAvailable * 1024;
    int maxSemiSpaceMb = 512;
    int maxExecutableSizeMb = 512;
  
    v8::V8::InitializeICUDefaultLocation(argv[0]);
    v8::V8::InitializeExternalStartupData(argv[0]);
    this-&gt;_platform = v8::platform::CreateDefaultPlatform();
    this-&gt;_create_params.array_buffer_allocator =
    v8::ArrayBuffer::Allocator::NewDefaultAllocator();
  
    const uint64_t physical_memory = this-&gt;_maxRAMAvailable * 1024 * 1024 * 1024;
    const uint64_t virtual_memory_limit = 0;
    this-&gt;_create_params.constraints.ConfigureDefaults(physical_memory, virtual_memory_limit);
  
    this-&gt;_create_params.constraints.set_max_old_space_size(maxOldSpaceMb);
    this-&gt;_create_params.constraints.set_max_semi_space_size(maxSemiSpaceMb);
  </code></pre>
  
  <p>this->_create_params.constraints.set_max_executable_size(maxExecutableSizeMb);</p>
  
  <pre><code>  v8::V8::InitializePlatform(this-&gt;_platform);
    v8::V8::Initialize();
  </code></pre>
  
  <p>Many thanks!</p>