Automattic / Automattic/node-canvas
Utility method loadImage memory leak
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 1.2k
- Avg merge
- 4d 8h
- Merged PRs (30d)
- 1
Description
## Issue
Calling the utility method `loadImage` (or just using the `Image` object for the matter) does not release the memory used.
The same happens with both local and remote images. Loading a 3MB remote jpg in the below example would keep the rss memory at ~400MB and would not be GCed.
Awaiting for the promise to resolve, setting the returned image to null / the source to null makes no difference to the memory level.
## Steps to Reproduce
```js
const { loadImage } = require('canvas')
for (let i=1; i<=10; i++) {
loadImage('path_to_image').then(function(){
console.log('loaded')
})
}
setInterval(()=>{
if (global.gc) { global.gc() }
console.log('rss: ' + process.memoryUsage().rss / (1024 * 1024) + 'MB')
}, 1000)
```
## Your Environment
* Version of node-canvas: 2.6.1 built from source
* Environment: node 12.19.1 & node 14.15.1 on MacOS 10.13.6 & Heroku 18 stack (Ubuntu 18.04)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.