Skip to content

Commit

Permalink
fix: memory leak on component unmounting
Browse files Browse the repository at this point in the history
reference and proxy to the components where preventing GC
fix for #23
  • Loading branch information
EmixamPP committed Jul 2, 2024
1 parent 2624892 commit 75dae5a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/render/react/core/reconciler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const HostConfig = {
workInProgress,
uid,
);
instanceMap[uid] = instance;
return instance;
},
createTextInstance: (
Expand Down Expand Up @@ -124,12 +123,16 @@ const HostConfig = {
commitTextUpdate(textInstance, oldText, newText) {
textInstance.setText(newText);
},
detachDeletedInstance: (instance) => {
unRegistEvent(instance.uid);
instanceMap.delete(instance.uid);
instance.style = null; // Proxy preventing GC
},
removeChild(parent, child) {
parent?.removeChild(child);
unRegistEvent(child.uid);
delete instanceMap[child.uid];
},
commitMount: function (instance, type, newProps, internalInstanceHandle) {
instanceMap.set(instance.uid, instance);
const { commitMount } = getComponentByTagName(type);
return commitMount(instance, newProps, internalInstanceHandle);
},
Expand Down

0 comments on commit 75dae5a

Please sign in to comment.