Allow clearing cache, to avoid leaking of memory #5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The caching feature is super nice, but it's actually risky. If you
start creating big enough objects at a high frequency (less than 1
minute) then the cache starts growing and growing which leads to
a memory leak. This is more notoriuous on mobile devices, and
specially when the module is used to display 16MP images.
Here you can see the memory consumption of my ionic app after 7 creations and destruction's of pinch-zoom-canvas objects:
![object-leak](https://user-images.githubusercontent.com/545883/37248006-7504e8b4-24c6-11e8-8c02-5fe0e0a80b05.png)
And here you can see the same after I applied this patch:
![no-more-leak](https://user-images.githubusercontent.com/545883/37248011-7e4c51c8-24c6-11e8-9491-3b032ea7af2d.png)