Skip to content

Commit

Permalink
Fix memory leaks in Spine caused by not calling freeStoreMemory.
Browse files Browse the repository at this point in the history
  • Loading branch information
bofeng-song committed Dec 10, 2024
1 parent 35d27d6 commit d19d9a8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions cocos/spine/lib/spine-core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,7 @@ declare namespace spine {
class wasmUtil {
static spineWasmInit(): void;
static spineWasmDestroy(): void;
static freeStoreMemory(): void;
static queryStoreMemory(size: number): number;
static querySpineSkeletonDataByUUID(uuid: string): SkeletonData;
static createSpineSkeletonDataWithJson(jsonStr: string, atlasText: string): SkeletonData;
Expand Down
1 change: 1 addition & 0 deletions cocos/spine/skeleton-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export class SkeletonData extends Asset {
wasmMem.set(rawData);
this._skeletonCache = spine.wasmUtil.createSpineSkeletonDataWithBinary(byteSize, this._atlasText);
spine.wasmUtil.registerSpineSkeletonDataWithUUID(this._skeletonCache, uuid);
spine.wasmUtil.freeStoreMemory();
}

return this._skeletonCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,7 @@ EMSCRIPTEN_BINDINGS(cocos_spine) {
.class_function("spineWasmInit", &SpineWasmUtil::spineWasmInit)
.class_function("spineWasmDestroy", &SpineWasmUtil::spineWasmDestroy)
.class_function("queryStoreMemory", &SpineWasmUtil::queryStoreMemory)
.class_function("freeStoreMemory", &SpineWasmUtil::freeStoreMemory)
.class_function("querySpineSkeletonDataByUUID", &SpineWasmUtil::querySpineSkeletonDataByUUID, allow_raw_pointers())
.class_function("createSpineSkeletonDataWithJson", &SpineWasmUtil::createSpineSkeletonDataWithJson, allow_raw_pointers())
.class_function("createSpineSkeletonDataWithBinary", &SpineWasmUtil::createSpineSkeletonDataWithBinary, allow_raw_pointers())
Expand Down

0 comments on commit d19d9a8

Please sign in to comment.