Preventing PowerPoint extension from crashing due memory leak.
I've faced with issue that my PowerPoint extention and desktop web-site crashes due memory leak. When both the extension and the desktop version of the site are open simultaneously, and a presentation file larger than 25MB is loaded using Office.context.document.getFileAsync
, both applications crash during the final file slice due to a memory leak. This occurs without any error messages or network requests associated with the crash. Could you provide guidance on how to address this memory leak issue or improve the handling of large presentation files?
This is my get file function, and it works fine untill there is no open tab with desktop app.
Office.context.document.getFileAsync(Office.FileType.Compressed, function (result) {
if (result.status === Office.AsyncResultStatus.Failed) {
console.error('--| Error fetching presentation file:' + result.error.message);
return;
}
const myFile = result.value;
const sliceCount = myFile.sliceCount;
const fileSlices: ArrayBuffer[] = [];
let slicesReceived = 0;
const getSlice = (sliceIndex: number) => {
myFile.getSliceAsync(sliceIndex, (sliceResult) => {
if (sliceResult.status === Office.AsyncResultStatus.Failed) {
myFile.closeAsync();
console.error(
`--| Error fetching slice #${sliceIndex}: ${sliceResult.error.message}`
);
return;
}
fileSlices.push(sliceResult.value.data);
slicesReceived++;
// This block is never reached in described case
if (slicesReceived === sliceCount) {
myFile.closeAsync();
const file = transformBlobIntoFile(fileSlices);
setFile(file);
console.warn('--| Presentation file is selected:', file);
} else {
getSlice(slicesReceived);
}
});
};
getSlice(0);
});