Ok, to whoever reads this, do not try to run the above testcase on 4.4.
I tested that yesterday, and there is an huge memory leak, it goes up to 8
GiB in five seconds.
https://code.google.com/p/v8/issues/detail?id=4201
пятница, 19 июня 2015 г., 13:44:04 UTC+3 пользователь Никита Сковорода
написал:
>
> At, it looks like ArrayBuffer objects (and hence typed arrays) are
> collectable with scavenges, but they do not trigger scavenges themselves.
>
> Is there a reason for that behaviour? Is that done on a purpose to
> optimize some cases?
>
> Testcase, run with --expose-gc:
> 'use strict';
>
> var count = 0, limit = 1000000;
> var start = process.hrtime();
>
> var something = [];
> for (var j = 0; j < 200; j++) something.push(Math.random());
>
> /* -1 is the same as 0, serves as warmup (actual memory allocation etc) */
> var slices = -1, slicesLimit = 5;
>
> function call() {
> var buffer = new ArrayBuffer(16 * 1024);
> var bufferx;
> for (var j = 0; j < slices; j++) bufferx = something.slice();
> count++;
> if (count > limit) {
> console.log(slices, process.hrtime(start));
> slices++;
> if (slices > slicesLimit) {
> process.exit(0);
> }
> count = 0;
> gc();gc();gc();gc();
> start = process.hrtime();
> }
> setImmediate(call);
> }
>
> for (var i = 0; i < 20; i++) {
> call();
> }
> This is io-js based, but you could do the same with pure v8, replacing or
> commenting out console.log, process.hrtime, and process.exit and running
> with --trace-gc.
>
> Results ({slices} [{time}]):
> -1 [ 11, 492942444 ]
> 0 [ 7, 152229091 ]
> 1 [ 7, 748195903 ]
> 2 [ 10, 344260005 ]
> 3 [ 6, 310061331 ]
> 4 [ 7, 45277127 ]
> 5 [ 7, 403463068 ]
>
> The code above just creates a bunch of array buffers and {slices} of
> 200-element Array slices for each buffer to push the scavenges threshold.
>
> Ignore the -1 row, it's for the warmup.
> As you can see (and as you could check with --trace-gc), when {slices} is
> less than 3, ArrayBuffer instances are pushing the mark-sweep threshold
> faster than Array slices push the scavenges threshold, so mark-sweeps are
> triggered and everything is collected via mark-sweeps.
> But when {slices} is equal to 3 or more, Array slices pushing scavenges
> threshold outweights ArrayBuffer instances pushing mark-sweep threshold, so
> scavenges are triggered instead of mark-sweeps, and everything gets
> collected using scavenges perfectly fine. And faster, too.
>
> The above is tested on 4.2 and 4.3.
>
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.