Skip to content

Conversation

anthrax63
Copy link
Contributor

In my application, I have seen that the consumed process memory grows over time. As a result of research, I found that some methods allocate memory in C code that is never freed. This pull request solves this problem. Also method drawPageAsPNGRaw has been added, which immediately returns binary data. Also was fixed small issue - all methods returning strings had null byte at the end. Now this byte is truncated.

@andytango andytango self-requested a review July 7, 2023 07:55
@andytango
Copy link
Owner

Thanks @anthrax63 - I will review these changes and merge next week

@rambo-panda
Copy link

rambo-panda commented Aug 25, 2023

@andytango Do you have any plans to merge in the near future? I am currently facing this issue as well?
image

@anthrax63 when I use the package you published, I find that there are still memory leaks present

import { createMuPdfWithoutContext } from "@cahva/mupdf-js";
//const save2imgs =require("./libs/save2img.js");

(async () => {
  for (let i = 0; i < 5; i++) {
    const mupdf = await createMuPdfWithoutContext();
    const ctx = mupdf.createContext();
    const doc = mupdf.load(ctx, buf);

    console.log(mupdf.drawPageAsPNG(ctx, doc, 1, 300).length);
    mupdf.freeDocument(doc);
    mupdf.freeContext(ctx);
  }
})();

setInterval(() => {
   // mock something
}, 50000);
image
  • node : v18.15.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants