[quickjs-devel] JS_SetMemoryLimit not working as expected

  • From: JM <jeevhi@xxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Thu, 23 Jan 2020 15:45:42 +0530

I have set the memory limit to 128K using the following code:

JS_SetMemoryLimit(rt, 128*1024);

I expected the following script to generate an exception after 13
iterations.  However, it takes 326 iterations to generate out of memory
exception.

var a = [];
for(var i=0; i < 1000; i++) {
         print(i);
          a[i] = new Array(10000);
}

Can someone explain what am I doing wrong?

Other related posts: