The Resize method can cause memory leaks.
oubenruing opened this issue · comments
Hi,
I found that using the Resize method can cause memory leaks during my usage. Here is a reproducible code snippet:
import gl from 'gl';
const context = gl(1, 1);
const ext = context.getExtension('STACKGL_resize_drawingbuffer');
ext.resize(Math.round(Math.random() * 10000), Math.round(Math.random() * 10000));
console.log(process.memoryUsage());
ext.resize(Math.round(Math.random() * 10000), Math.round(Math.random() * 10000));
console.log(process.memoryUsage());
ext.resize(Math.round(Math.random() * 10000), Math.round(Math.random() * 10000));
console.log(process.memoryUsage());
ext.resize(Math.round(Math.random() * 10000), Math.round(Math.random() * 10000));
console.log(process.memoryUsage());
global.gc();
console.log(process.memoryUsage());
The output is as follows:
D:\nodejs\node.exe --expose-gc .\test\serve\index.js
{rss: 172564480, heapTotal: 14258176, heapUsed: 10961088, external: 993382, arrayBuffers: 25834}
{rss: 254685184, heapTotal: 14528512, heapUsed: 11019784, external: 993494, arrayBuffers: 25906}
{rss: 464908288, heapTotal: 14528512, heapUsed: 11177264, external: 993566, arrayBuffers: 25978}
{rss: 548601856, heapTotal: 14528512, heapUsed: 11415536, external: 993670, arrayBuffers: 26082}
{rss: 545845248, heapTotal: 11382784, heapUsed: 8534216, external: 992516, arrayBuffers: 24970}
The RSS keeps increasing and the total memory usage does not decrease even after invoking GC manually.
Environment:
Microsoft Windows NT 10.0.19044.0 x64
node v18.15.0
gl 6.0.2
Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz
NVIDIA GeForce GTX 1050