20000000 bytes = just over 19 MiB BTW. And that's assuming it's all bytes.

In reality, it'd take closer to 4x at minimum, as these would be stored as 
32-bit integers (or 4 bytes per element), and that would come out to about 
76.3 MiB. If that's even completing, that's a bug in V8 IMHO, and a 
potential security bug at that.

On Monday, August 15, 2022 at 6:42:35 PM UTC-7 [email protected] wrote:

> Hello,
>
> This is a noob question, but I'm trying to set a low heap size (4MiB) for 
> an embedded application and I can't seem to succeed.
>
> I also tried setting both a near limit callback and a GC epilogue and they 
> don't get called.
>
> I am initializing the Isolate with constraints set 
> via ConfigureDefaultsFromHeapSize with both initial and max heap sizes set 
> to 4MiB.
>
> I'm trying to run a script that has just "a = Array(20000000).fill(2)".
>
> Heap statistics right after Isolate initialization:
>
> total_heap=962560 total_heap_executable=524288 total_physical=438272 
> total_available=4246240 total_global_handles=0 used_heap=371424 
> heap_limit=4194304 malloced=16460 external=0 peak_malloced=8192 
> native_ctx=0 detached_ctx=0 zap_garbage=0
>
> Heap statistics right after running the script:
>
> heap total_heap=41496576 total_heap_executable=524288 
> total_physical=40568044 total_available=485100 total_global_handles=8192 
> used_heap=40900828 heap_limit=4194304 malloced=16460 external=0 
> peak_malloced=49208 native_ctx=1 detached_ctx=0 zap_garbage=0
>
> Note that the total heap size is 40 MiB, despite the limit being 4 MiB.
>
> Am I doing something obviously wrong? This is v8 10.0.139.15.
>
> Thanks,
> -Tudor.
>

-- 
-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- 
You received this message because you are subscribed to the Google Groups 
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-dev/a35bea43-39c0-4e66-ae19-8845dbb0a85en%40googlegroups.com.

Reply via email to