memory leak with webgl ,
driver version 440.82
card : Quadro RTX 8000
os: centos 7, 64bit
i try following code on Mac, memory was not leak.
Same code on centos, memory leak , please help me
gpu memory usage keep rising ,
<------------------------------- code below ------------------------------------>
const fs = require(‘fs’)
const path = require(‘path’)
const puppeteer = require(‘puppeteer’)
const three = fs.readFileSync(path.join(__dirname, “…/node_modules/three/build/three.js”), ‘utf-8’)
async function file2base64 (path) {
const data = await new Promise(resolve => {
fs.readFile(path, (err, data) => {
if (err) throw err
resolve(data)
})
})
return data.toString(‘base64’)
}
let browser, page
async function initBrowser () {
const dArgs = puppeteer.defaultArgs()
dArgs.push(‘–no-sandbox’)
dArgs.push(‘–use-gl=egl’)
dArgs.push(‘–disable-accelerated-2d-canvas’)
browser = await puppeteer.launch({
ignoreDefaultArgs: true,
// devtools: true,
dumpio: true,
args: dArgs,
})
}
async function initPage () {
try {
page = await browser.newPage()
await Promise.all([
// page.setCacheEnabled(false),
page.addScriptTag({content: three}),
])
} catch (e) {
console.log('initPageError: ', e)
await browser.close()
process.exit()
}
}
async function initContext () {
await initBrowser()
await initPage()
}
async function evaluate () {
await page.evaluate(async (base64) => {
let camera, scene, renderer;
init();
animate();
function init() {
const container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 10 );
camera.position.z = 2;
scene = new THREE.Scene();
scene.background = new THREE.Color( 0xffffff );
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
}
async function createImage() {
return await new Promise(resolve => {
new THREE.TextureLoader().load(`data:image/png;base64, ${base64}`, resolve)
})
}
//
function animate() {
setTimeout( animate , 1000);
render();
}
async function render() {
const geometry = new THREE.BoxGeometry(1, 1, 1);
const texture = await createImage() ;
const material = new THREE.MeshBasicMaterial( { map: texture } );
const mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
renderer.render( scene, camera )
scene.remove( mesh );
// clean up
geometry.dispose();
material.dispose();
texture.dispose();
}
}, await file2base64(‘/filePath/please/replace/this/path’))
}
;(async () => {
await initContext()
await evaluate()
})()