Re-use resource class for remote sideloads (avoid memory leak) #421
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.
Dynamically creating resource classes for each sideload is expensive on
allocations and it was causing a memory leak on carwow's production
applications since these Class objects were not being freed.
Not sure if there was anything in particular to our applications that
was preventing these Class objects from being freed, but even if there
is no memory leak on a simple application, it is still expensive and slow
in terms of allocations.
When running a memory-profiler and doing an HTTP requests that
includes/sideloads resources from a remote resource, you should be able
to see something like:
This PR proposes defining a static resource class for remote sideloads
which can be re-used:
RemoteSideloadResource
.