diff --git a/js/web/lib/wasm/wasm-training-core-impl.ts b/js/web/lib/wasm/wasm-training-core-impl.ts index 37e226aff2d9c..dd1b38d09fe81 100644 --- a/js/web/lib/wasm/wasm-training-core-impl.ts +++ b/js/web/lib/wasm/wasm-training-core-impl.ts @@ -87,6 +87,7 @@ const getModelInputOutputNamesLoop = ifErrCodeCheckLastError(name, `Can't get input or output name -- is input: ${isInput}, index ${i}`, false); names.push(wasm.UTF8ToString(name)); + wasm._free(name); } else { throw new Error(NO_TRAIN_FUNCS_MSG); } @@ -506,14 +507,13 @@ export const loadParametersBuffer = } }; -export const releaseTrainingSessionAndCheckpoint = - (checkpointId: number, sessionId: number): void => { - const wasm = getInstance(); +export const releaseTrainingSessionAndCheckpoint = (checkpointId: number, sessionId: number): void => { + const wasm = getInstance(); - if (wasm._OrtTrainingReleaseSession) { - wasm._OrtTrainingReleaseSession(sessionId); - } - if (wasm._OrtTrainingReleaseCheckpoint) { - wasm._OrtTrainingReleaseCheckpoint(checkpointId); - } - }; + if (wasm._OrtTrainingReleaseSession) { + wasm._OrtTrainingReleaseSession(sessionId); + } + if (wasm._OrtTrainingReleaseCheckpoint) { + wasm._OrtTrainingReleaseCheckpoint(checkpointId); + } +};