v8  7.8.279(node12.19.0)
V8 is Google's open source JavaScript engine
ResourceConstraints Class Reference

#include <v8.h>

Public Member Functions

void ConfigureDefaultsFromHeapSize (size_t initial_heap_size_in_bytes, size_t maximum_heap_size_in_bytes)
 
void ConfigureDefaults (uint64_t physical_memory, uint64_t virtual_memory_limit)
 
uint32_t * stack_limit () const
 
void set_stack_limit (uint32_t *value)
 
size_t code_range_size_in_bytes () const
 
void set_code_range_size_in_bytes (size_t limit)
 
size_t max_old_generation_size_in_bytes () const
 
void set_max_old_generation_size_in_bytes (size_t limit)
 
size_t max_young_generation_size_in_bytes () const
 
void set_max_young_generation_size_in_bytes (size_t limit)
 
size_t initial_old_generation_size_in_bytes () const
 
void set_initial_old_generation_size_in_bytes (size_t initial_size)
 
size_t initial_young_generation_size_in_bytes () const
 
void set_initial_young_generation_size_in_bytes (size_t initial_size)
 
 V8_DEPRECATE_SOON ("Use code_range_size_in_bytes.", size_t code_range_size() const)
 
 V8_DEPRECATE_SOON ("Use set_code_range_size_in_bytes.", void set_code_range_size(size_t limit_in_mb))
 
 V8_DEPRECATE_SOON ("Use max_young_generation_size_in_bytes.", size_t max_semi_space_size_in_kb() const)
 
 V8_DEPRECATE_SOON ("Use set_max_young_generation_size_in_bytes.", void set_max_semi_space_size_in_kb(size_t limit_in_kb))
 
 V8_DEPRECATE_SOON ("Use max_old_generation_size_in_bytes.", size_t max_old_space_size() const)
 
 V8_DEPRECATE_SOON ("Use set_max_old_generation_size_in_bytes.", void set_max_old_space_size(size_t limit_in_mb))
 
 V8_DEPRECATE_SOON ("Zone does not pool memory any more.", size_t max_zone_pool_size() const)
 
 V8_DEPRECATE_SOON ("Zone does not pool memory any more.", void set_max_zone_pool_size(size_t bytes))
 

Detailed Description

A set of constraints that specifies the limits of the runtime's memory use. You must set the heap size before initializing the VM - the size cannot be adjusted after the VM is initialized.

If you are using threads then you should hold the V8::Locker lock while setting the stack limit and you must set a non-default stack limit separately for each thread.

The arguments for set_max_semi_space_size, set_max_old_space_size, set_max_executable_size, set_code_range_size specify limits in MB.

The argument for set_max_semi_space_size_in_kb is in KB.

Definition at line 6558 of file v8.h.

Member Function Documentation

◆ code_range_size_in_bytes()

size_t code_range_size_in_bytes ( ) const
inline

The amount of virtual memory reserved for generated code. This is relevant for 64-bit architectures that rely on code range for calls in code.

Definition at line 6603 of file v8.h.

◆ ConfigureDefaults()

void ConfigureDefaults ( uint64_t  physical_memory,
uint64_t  virtual_memory_limit 
)

Configures the constraints with reasonable default values based on the capabilities of the current device the VM is running on.

Parameters
physical_memoryThe total amount of physical memory on the current device, in bytes.
virtual_memory_limitThe amount of virtual memory on the current device, in bytes, or zero, if there is no limit.

◆ ConfigureDefaultsFromHeapSize()

void ConfigureDefaultsFromHeapSize ( size_t  initial_heap_size_in_bytes,
size_t  maximum_heap_size_in_bytes 
)

Configures the constraints with reasonable default values based on the provided heap size limit. The heap size includes both the young and the old generation.

Parameters
initial_heap_size_in_bytesThe initial heap size or zero. By default V8 starts with a small heap and dynamically grows it to match the set of live objects. This may lead to ineffective garbage collections at startup if the live set is large. Setting the initial heap size avoids such garbage collections. Note that this does not affect young generation garbage collections.
maximum_heap_size_in_bytesThe hard limit for the heap size. When the heap size approaches this limit, V8 will perform series of garbage collections and invoke the NearHeapLimitCallback. If the garbage collections do not help and the callback does not increase the limit, then V8 will crash with V8::FatalProcessOutOfMemory.

◆ initial_old_generation_size_in_bytes()

size_t initial_old_generation_size_in_bytes ( ) const
inline

Definition at line 6632 of file v8.h.

◆ initial_young_generation_size_in_bytes()

size_t initial_young_generation_size_in_bytes ( ) const
inline

Definition at line 6639 of file v8.h.

◆ max_old_generation_size_in_bytes()

size_t max_old_generation_size_in_bytes ( ) const
inline

The maximum size of the old generation. When the old generation approaches this limit, V8 will perform series of garbage collections and invoke the NearHeapLimitCallback. If the garbage collections do not help and the callback does not increase the limit, then V8 will crash with V8::FatalProcessOutOfMemory.

Definition at line 6613 of file v8.h.

◆ max_young_generation_size_in_bytes()

size_t max_young_generation_size_in_bytes ( ) const
inline

The maximum size of the young generation, which consists of two semi-spaces and a large object space. This affects frequency of Scavenge garbage collections and should be typically much smaller that the old generation.

Definition at line 6625 of file v8.h.

◆ set_code_range_size_in_bytes()

void set_code_range_size_in_bytes ( size_t  limit)
inline

Definition at line 6604 of file v8.h.

◆ set_initial_old_generation_size_in_bytes()

void set_initial_old_generation_size_in_bytes ( size_t  initial_size)
inline

Definition at line 6635 of file v8.h.

◆ set_initial_young_generation_size_in_bytes()

void set_initial_young_generation_size_in_bytes ( size_t  initial_size)
inline

Definition at line 6642 of file v8.h.

◆ set_max_old_generation_size_in_bytes()

void set_max_old_generation_size_in_bytes ( size_t  limit)
inline

Definition at line 6616 of file v8.h.

◆ set_max_young_generation_size_in_bytes()

void set_max_young_generation_size_in_bytes ( size_t  limit)
inline

Definition at line 6628 of file v8.h.

◆ set_stack_limit()

void set_stack_limit ( uint32_t *  value)
inline

Definition at line 6597 of file v8.h.

◆ stack_limit()

uint32_t* stack_limit ( ) const
inline

The address beyond which the VM's stack may not grow.

Definition at line 6596 of file v8.h.

◆ V8_DEPRECATE_SOON() [1/8]

V8_DEPRECATE_SOON ( "Use code_range_size_in_bytes."  ,
size_t code_range_size() const   
)
inline

Deprecated functions. Do not use in new code.

Definition at line 6649 of file v8.h.

◆ V8_DEPRECATE_SOON() [2/8]

V8_DEPRECATE_SOON ( "Use max_old_generation_size_in_bytes."  ,
size_t max_old_space_size() const   
)
inline

Definition at line 6661 of file v8.h.

◆ V8_DEPRECATE_SOON() [3/8]

V8_DEPRECATE_SOON ( "Use max_young_generation_size_in_bytes."  ,
size_t max_semi_space_size_in_kb() const   
)

◆ V8_DEPRECATE_SOON() [4/8]

V8_DEPRECATE_SOON ( "Use set_code_range_size_in_bytes."  ,
void   set_code_range_sizesize_t limit_in_mb 
)
inline

Definition at line 6653 of file v8.h.

◆ V8_DEPRECATE_SOON() [5/8]

V8_DEPRECATE_SOON ( "Use set_max_old_generation_size_in_bytes."  ,
void   set_max_old_space_sizesize_t limit_in_mb 
)
inline

Definition at line 6665 of file v8.h.

◆ V8_DEPRECATE_SOON() [6/8]

V8_DEPRECATE_SOON ( "Use set_max_young_generation_size_in_bytes."  ,
void   set_max_semi_space_size_in_kbsize_t limit_in_kb 
)

◆ V8_DEPRECATE_SOON() [7/8]

V8_DEPRECATE_SOON ( "Zone does not pool memory any more."  ,
size_t max_zone_pool_size() const   
)
inline

Definition at line 6669 of file v8.h.

◆ V8_DEPRECATE_SOON() [8/8]

V8_DEPRECATE_SOON ( "Zone does not pool memory any more."  ,
void   set_max_zone_pool_sizesize_t bytes 
)
inline

Definition at line 6673 of file v8.h.


The documentation for this class was generated from the following file: