Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential Memory Leak with Pica Usage in High-Frequency Resizing #247

Open
Abhinandan777 opened this issue Dec 23, 2024 · 0 comments
Open

Comments

@Abhinandan777
Copy link

Hi,

Thank you for creating and maintaining this great library!

I’m using Pica to resize images uploaded by users in my application. Currently, I’m creating a new instance of Pica for every uploaded image, as shown below:

img.onload = async () => {
  let picaInstance = pica();
  try {
    const blob = await picaInstance.resize(img, canvas, { quality: 3 });
    // Additional processing...
  } catch (error) {
    console.error(error);
  }
};

Recently, we noticed a memory spike in our application during high-frequency uploads. I suspect it might be related to creating a new Pica instance for each upload.

My questions are:

  • Could creating multiple Pica instances cause memory issues or inefficiencies in this scenario?

  • Would it be better to move the Pica instance outside the function and reuse it globally?

For context:

  • The application handles multiple concurrent uploads.

  • Performance and memory optimization are priorities.

I’d appreciate any guidance or recommendations for best practices when using Pica in this way.

Thank you for your help!

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

No branches or pull requests

1 participant