mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
gc massage
This commit is contained in:
parent
a900c36395
commit
b69a563fc2
|
@ -24,6 +24,7 @@ function load_fb() {
|
||||||
|
|
||||||
|
|
||||||
var reader = null,
|
var reader = null,
|
||||||
|
gc1, gc2, gc3,
|
||||||
busy = false;
|
busy = false;
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,9 +40,14 @@ onmessage = (d) => {
|
||||||
|
|
||||||
reader.onload = function (e) {
|
reader.onload = function (e) {
|
||||||
try {
|
try {
|
||||||
|
// chrome gc forgets the filereader output; remind it
|
||||||
|
gc1 = e.target.result;
|
||||||
|
gc2 = new Uint8Array(gc1, 0, 1);
|
||||||
|
gc3 = new Uint8Array(gc1, gc1.byteLength - 1);
|
||||||
|
|
||||||
//console.log('[ w] %d HASH bgin', nchunk);
|
//console.log('[ w] %d HASH bgin', nchunk);
|
||||||
postMessage(["read", nchunk, cdr - car, Date.now() - t0]);
|
postMessage(["read", nchunk, cdr - car, Date.now() - t0]);
|
||||||
hash_calc(e.target.result);
|
hash_calc(gc1);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
postMessage(["panic", ex + '']);
|
postMessage(["panic", ex + '']);
|
||||||
|
@ -66,6 +72,11 @@ onmessage = (d) => {
|
||||||
|
|
||||||
var hash_calc = function (buf) {
|
var hash_calc = function (buf) {
|
||||||
var hash_done = function (hashbuf) {
|
var hash_done = function (hashbuf) {
|
||||||
|
// stop gc from attempting to free early
|
||||||
|
if (!gc1 || !gc2 || !gc3)
|
||||||
|
return console.log('torch went out');
|
||||||
|
|
||||||
|
gc1 = gc2 = gc3 = null;
|
||||||
busy = false;
|
busy = false;
|
||||||
try {
|
try {
|
||||||
var hslice = new Uint8Array(hashbuf).subarray(0, 33);
|
var hslice = new Uint8Array(hashbuf).subarray(0, 33);
|
||||||
|
@ -77,6 +88,10 @@ onmessage = (d) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// stop gc from attempting to free early
|
||||||
|
if (!gc1 || !gc2 || !gc3)
|
||||||
|
console.log('torch went out');
|
||||||
|
|
||||||
if (subtle)
|
if (subtle)
|
||||||
subtle.digest('SHA-512', buf).then(hash_done);
|
subtle.digest('SHA-512', buf).then(hash_done);
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue