Hi, I have found an issue about Spine. When set skeletonData to null, any subsequence set data other than null will cause memory leak.
My experiment like this:
@ccclass("Test")
export class Test extends Component {
@property(sp.Skeleton) ske: sp.Skeleton = null;
@property(sp.SkeletonData) skeData: sp.SkeletonData = null;
private _turn = 0;
start() {}
update(deltaTime: number) {
if (this._turn === 0) {
this.ske.skeletonData = null;
} else {
this.ske.skeletonData= this.skeData;
this.ske.setAnimation(0, 'idle', true);
}
this._turn = (this._turn + 1) % 2;
}
}
run this for a while the heap memory will always increase
Here is my demo project
TestSpineLeak.zip (6.6 MB)
This issue will be fixed in the 3.8.2 version, and the official PR is: https://github.com/cocos/cocos-engine/pull/16384 .
Here is a temporary solution:
Download the spine wasm file and place it in the engine folder. The folder path is as follows:
spine.zip (348.5 KB)
C:\ProgramData\cocos\editors\Creator\3.8.0\resources\resources\3d\engine\native\external\emscripten\spine
After that, refer to the temporary PR to modify the engine code:
committed 09:55AM - 10 Oct 23 UTC
Or download and replace the file directly. The folder path for replacement is as follows:
spine.zip (33.5 KB)
C:\ProgramData\cocos\editors\Creator\3.8.0\resources\resources\3d\engine\cocos\spine
Finally, click the compile engine button and wait for the console to display ‘Quick Compile’.
tuan243
October 11, 2023, 6:09am
#3
Hi, this issue is fixed. However, I find another issue with spine cause memory leak.
Our game use a lot of spine. I add about 40 spine instance to scene (cache mode realtime, some spine have enable batch). The memory using will still increase after some interval (30s - 1 min).
My scene set up look like this:
It seem your team have aware that spine is causing memory leak before this first post. Can you help me to fix this?
Hello, I tested the new issue you mentioned and did not find any abnormalities. Please provide me with the test project.
tuan243
October 12, 2023, 6:50am
#5
Here is the test project
Spine3-8-leak.zip (261.3 KB)
Here is heap snapshots I capture for 1 minute each (total 10 min)
1 Like
tuan243
October 17, 2023, 10:10am
#7
Hi, I have tested with this repaired engine and the issue still persists. I have downloaded the engine, change the path, restart the editor, select Compile the Engine, clear code Cache. Am I missing something?
It looks like there are no missing steps. It may be easier to solve the problem when Cocos Creator v3.8.2 is released.
tuan243
October 18, 2023, 7:18am
#9
Ok, I will stick with Cocos 3.7.2 for now