Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak #49

Closed
DengCun opened this issue Nov 22, 2019 · 2 comments
Closed

memory leak #49

DengCun opened this issue Nov 22, 2019 · 2 comments

Comments

@DengCun
Copy link

DengCun commented Nov 22, 2019

This heapened when I use Google Chrome .
When I load a big model (1GB) using the following code ,it uses a lot of memory
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
<script type="module">
import { OBJLoader2 } from "./jsm/loaders/OBJLoader2.js";
( function () {
let objLoader2 = new OBJLoader2();
let callbackOnLoad = function ( object3d ) {
console.log("success");
};
objLoader2.setModelName( "modelName" );
objLoader2.load( 'test_model/test2.obj', callbackOnLoad, null, null, null );
} )();
</script>
</html>
The garbage collection should clear the memory which stores the model , but it didn't do that,is
it memory leak?
.

When I load using the following code,just add more line " delete objLoader2.parser.contentRef;" in callbackOnLoad function
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
</body>
<script type="module">
import { OBJLoader2 } from "./jsm/loaders/OBJLoader2.js";
( function () {
let objLoader2 = new OBJLoader2();
let callbackOnLoad = function ( object3d ) {
delete objLoader2.parser.contentRef;
console.log("success");
};
objLoader2.setModelName( "modelName" );
objLoader2.load( 'test_model/test2.obj', callbackOnLoad, null, null, null );
} )();
</script>
</html>
the memory which stores the model will be clear;

@Cobertos
Copy link
Contributor

Cobertos commented Nov 22, 2019

Google Chrome has had this issue for years now, the old OBJLoader had this issue in THREE.js and there's kind of a hacky fix to release the memory but it's not great.

Fortunately for you, the Chromium bug just got assigned, coincidentally, https://bugs.chromium.org/p/v8/issues/detail?id=2869#c22

@kaisalmen
Copy link
Owner

@Cobertos Thank you for providing the connection to the other issue. I was not aware of this.
@DengCun I am hesitant to put the delete statement inside the parse function as this is solely a Chrome issue. Are you ok with the workaround you found?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants