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

fix memory leaks #7424

Merged
merged 6 commits into from Sep 21, 2020
Merged

Conversation

holycanvas
Copy link
Contributor

@holycanvas holycanvas commented Sep 21, 2020

Re: cocos-creator/2d-tasks#

Changes:

  • fix memory leaks
  • check bundle before create one

@@ -494,9 +494,9 @@ var Sprite = cc.Class({
oldFrame.off('load', this._applySpriteSize, this);
}

this._updateMaterial();
Copy link
Contributor Author

@holycanvas holycanvas Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

即使 spriteFrame 为空,也应该更新 material ,否则 material 里面会存着老的 texture,导致在原生上 texture 释放不了

wrapT: undefined,
format: undefined,
genMipmaps: undefined,
images: undefined,
Copy link
Contributor Author

@holycanvas holycanvas Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉没必要用全局对象省这点性能。现在用了一个全局对象,然后这个 sharedOpts 的 image 在提交后并没有把 image 清空,导致在原生上这部分内存一直释放不了

Copy link
Member

@jareguo jareguo Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

关键是这个地方的提交,是什么时候引发的?场景加载中的话可能会影响到性能。如果是用户手动调用才会触发就无所谓。

Copy link
Contributor Author

@holycanvas holycanvas Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

都会触发

Copy link
Contributor Author

@holycanvas holycanvas Sep 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先回退了,原生可能会受影响,先不改了

@holycanvas holycanvas requested review from 2youyou2 and xianyinchen Sep 21, 2020
@holycanvas holycanvas merged commit f70fef2 into cocos:v2.4.3-release Sep 21, 2020
1 check passed
holycanvas added a commit to holycanvas/engine that referenced this pull request Oct 9, 2020
holycanvas added a commit that referenced this pull request Oct 9, 2020
holycanvas added a commit to holycanvas/engine that referenced this pull request Oct 9, 2020
holycanvas added a commit that referenced this pull request Oct 9, 2020
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

Successfully merging this pull request may close these issues.

None yet

3 participants