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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions cocos2d/core/asset-manager/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
****************************************************************************/
const Bundle = require('./bundle');
const Cache = require('./cache');
const { assets } = require('./shared');
const { assets, bundles } = require('./shared');

const _creating = new Cache();

Expand Down Expand Up @@ -83,9 +83,12 @@ function createAsset (id, data, options, onComplete) {
}

function createBundle (id, data, options, onComplete) {
let bundle = new Bundle();
data.base = data.base || id + '/';
bundle.init(data);
let bundle = bundles.get(data.name);
if (!bundle) {
bundle = new Bundle();
data.base = data.base || id + '/';
bundle.init(data);
}
onComplete && onComplete(null, bundle);
}

Expand Down
2 changes: 1 addition & 1 deletion cocos2d/core/components/CCSprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ var Sprite = cc.Class({
oldFrame.off('load', this._applySpriteSize, this);
}

this._updateMaterial();
Copy link
Contributor Author

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 释放不了

let spriteFrame = this._spriteFrame;
if (spriteFrame) {
this._updateMaterial();
let newTexture = spriteFrame.getTexture();
if (newTexture && newTexture.loaded) {
this._applySpriteSize();
Expand Down