Preventing PowerPoint extension from crashing due memory leak.

Володимир Кравчук 10 Reputation points
2024-08-10T13:13:05.2566667+00:00

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);
  });
PowerPoint
PowerPoint
A family of Microsoft presentation graphics products that offer tools for creating presentations and adding graphic effects like multimedia objects and special effects with text.
291 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
981 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,896 questions
0 comments No comments
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.