Skip to content

Memory leaks and handles that cannot be released under Windows #54

Description

@chp1972

In Task Manager, you can see that even after using win.dispose(), or even app.exit(), the number of handles does not decrease.
node --expose-gc test.js

import { Application } from '@webviewjs/webview';
let app = new Application();
(async function(){
	await app.whenReady();
	console.log(`#0:rss=`,process.memoryUsage().rss);
	console.log('please check the number of handles in Task Manager');
	await new Promise(ok=>setTimeout(ok,30000));//pause for check
	let list=[];
	for(let i=0;i<50;i++){
		let win=app.createBrowserWindow({
			width:300,height:200,windowsSkipTaskbar:true
		});
		win.createWebview({html:`<h1>${i}</h2>`});
		list.push(win);
	}
	console.log(`#1:rss=`,process.memoryUsage().rss);
	await new Promise(ok=>setTimeout(ok,1000));
	console.log(`#2:rss=`,process.memoryUsage().rss);
	for(let win of list)
		win.dispose();
	list=[];
	global.gc();//need --expose-gc for nodejs
	await new Promise(ok=>setTimeout(ok,1000));
	console.log(`#3:rss=`,process.memoryUsage().rss);
	app.exit();
	app=null;
	await new Promise(ok=>setTimeout(ok,1000));
	console.log(`#4:rss=`,process.memoryUsage().rss);
	console.log('please check the number of handles again');
})()
setTimeout(() => {//keep alive 5 minutes for check count of handles
	console.log('the end');
}, 5*60*1000);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions