Skip to content

Commit

Permalink
fix mem leak from groups array
Browse files Browse the repository at this point in the history
  • Loading branch information
hrgdavor committed Sep 14, 2024
1 parent 2038007 commit 9da7ddf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/render-threejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function RenderThreejs({
let renderTimer
let meshColor = new Color(1, 1, 1)

const entities = []
let entities = []
const groups = []
let canvas

Expand Down Expand Up @@ -202,10 +202,12 @@ export function RenderThreejs({
groups.forEach(group => {
_scene.remove(group)
})
entities.forEach(ent => {
if (ent.geometry) ent.geometry.dispose()
})
entities.length = 0
let old = entities
entities = []
groups.length = 0
setTimeout(()=>{
old.forEach(ent => ent.geometry?.dispose?.())
},0)
scene.items.forEach(item => {
const group = new Group()
groups.push(group)
Expand Down

0 comments on commit 9da7ddf

Please sign in to comment.