How does Javascript allocates memory for strings? I ran this simple code in chrome:
var s = 'a';
var i;
for (i = 0; i < 5000000; i++) {
s += 'b';
}
var s2 = s;
s2[4000000] = 'a';
and attached Windbg to chrome, added conditional breakpoint in HeapAlloc, VirtualAlloc, and VirtualAllocEx with condition "requested bytes parameter > 4.5M".
when the above code ran I didn't see any such big allocation in the debugger.
I expected that at least for s2
I'll see such allocation.