There is a known bug in webkit that when you remove an image from the DOM, it doesn't free the memory associated with it.
This is an issue with single page apps that often load images.
Various suggested solutions are:
- Remove image src attribute before removing the image from the DOM
- Set image src to " " before removing the image from the DOM
- Set the image to a single pixel image before removing the image from the DOM
- Create a limited number of image elements and keep recycling them
The first 3 methods don't work for me. The main drawback to recycling image elements is that it means writing lots of code to manage that. I'm loading new HTML via AJAX that may contain images, so I don't necessarily know the number of images that will be loaded.
Are there any other work arounds to fix this problem?