This project is archived and is in readonly mode.
MASSIVE memory leak in AssetTag
Reported by aaronbatalion | November 19th, 2008 @ 07:07 PM
Every time you use a asset tag helper referencing a new asset url, references to the controller/template objects are stored in the AssetTag::Cache and never released.
If you render thousands of 3rd party images on your site, each image_tag call creates a hard reference in the AssetTag::Cache, which in turn references the controller/template, not allowing anything created in that request to leave scope, hence you have a massive memory leak.
The objects are cached b/c of filesystem access to determine the modified source string. E.g. "foo" -> "/stylesheets/foo.css"
The attached patch solves the issue by caching only the modified source strings, which is similar to the previous implementation, with a further optimization of caching only asset paths that are relative.
Comments and changes to this ticket
-
Jeremy Kemper November 19th, 2008 @ 07:14 PM
- State changed from new to open
- Assigned user set to josh
- Milestone cleared.
-
aaronbatalion November 19th, 2008 @ 09:11 PM
Wrote a quick blog post explaining the issue in more detail. http://blog.hungrymachine.com/20...
Also, I believe AssetTagCollection has the same problem, and isnt covered in my patch.
-
aaronbatalion November 19th, 2008 @ 11:15 PM
Attached is an updated patch that accounts for the assettag type being included in the cache key. Including the name of the class is better than self itself, against for hard references.
Also added a failing test that now passes.
-
josh November 19th, 2008 @ 11:22 PM
ah, I hate this cache. I should def look into preloading the asset folder contents on boot.
-
Repository November 19th, 2008 @ 11:29 PM
- State changed from open to resolved
(from [24dbd4b9581ba2affef9e8e96570200ee1e3266c]) Fixed asset host to not cache objects [#1419 state:resolved]
Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
-
Repository November 19th, 2008 @ 11:29 PM
(from [d7f4921a9a852da7c1075275eaf73822edb7acff]) Fixed asset host to not cache objects [#1419 state:resolved]
Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...
-
aaronbatalion November 19th, 2008 @ 11:35 PM
Josh, Please commit the 2nd patch. I found a bug that will mix js/css files and cache them as the same keys. This bug is still open.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 1419 MASSIVE memory leak in AssetTag (from [24dbd4b9581ba2affef9e8e96570200ee1e3266c]) Fixed a...
- 1419 MASSIVE memory leak in AssetTag (from [d7f4921a9a852da7c1075275eaf73822edb7acff]) Fixed a...