SetMemoryLimit the runtime memory limit; if not set, it will be unlimit.
(limit uint64)
| 679 | |
| 680 | // SetMemoryLimit the runtime memory limit; if not set, it will be unlimit. |
| 681 | func (r *Runtime) SetMemoryLimit(limit uint64) { |
| 682 | if r == nil { |
| 683 | return |
| 684 | } |
| 685 | if !r.ensureOwnerAccess() { |
| 686 | return |
| 687 | } |
| 688 | r.mu.RLock() |
| 689 | defer r.mu.RUnlock() |
| 690 | if r.closed.Load() || r.ref == nil { |
| 691 | return |
| 692 | } |
| 693 | C.JS_SetMemoryLimit(r.ref, C.size_t(limit)) |
| 694 | } |
| 695 | |
| 696 | // SetGCThreshold the runtime's GC threshold; use -1 to disable automatic GC. |
| 697 | func (r *Runtime) SetGCThreshold(threshold int64) { |