Skip to content

object URL memory leak in EditPromptModal when changing images #137

Description

@ayushgupta-h

What happened?

When editing a prompt and changing the image multiple times, each new image creates a new object URL via URL.createObjectURL(file), but the previous URLs are never cleaned up. This causes a memory leak that accumulates over time.

Steps to reproduce

  1. Open any prompt you own and click Edit
  2. Change the image 5-10 times in succession
  3. Open browser DevTools > Memory > Take heap snapshot
  4. Search for "blob:" — you'll see multiple unreleased object URLs

Where did you see this?

On parostudios.in

Console errors

In `src/components/prompts/EditPromptModal.tsx:68-74`:


const handleImageChange = (e: React.ChangeEvent<HTMLInputElement>) => {
  const file = e.target.files?.[0];
  if (file) {
    setImageFile(file);
    setImagePreview(URL.createObjectURL(file));  // Previous URL never revoked
  }
};

Browser and OS

No response

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions