#9284 closed patch
TOON: Cache recently used resources, rather than preloading
Reported by: | eriktorbjorn | Owned by: | sylvaintv |
---|---|---|---|
Priority: | normal | Component: | Engine: Toon |
Version: | Keywords: | ||
Cc: | Game: | Toonstruck |
Description
Some time ago, I mentioned to SylvainTV that the Toonstruck engine uses a lot of memory for preloading entire PAK files, DREW.PAK probably being the worst offender since it's 20 MB that remains in memory for the duration of the game. This patch is an attempt at keeping the memory usage down by caching resources as they are used. I haven't tested it much, but it seems to work for me.
It's built on the assumption that Resources::getFileData() is for short-lived data (typically read from file and immediately copied to another data structure), so it doesn't matter if the actual data is removed from the cache, while Resources::openFile() is for long-lived data which the engine itself is responsible for handling so it doesn't go through the cache at all.
I'm sure there's room for improvements, but at least this demonstrates that the concept could work.
Ticket imported from: #3194044. Ticket imported from: patches/1389.
Attachments (1)
Change History (7)
by , 14 years ago
Attachment: | toon-resourcecache.diff added |
---|
comment:1 by , 14 years ago
Owner: | set to |
---|
comment:3 by , 14 years ago
Apparently it was accepted with a few modifications. At the very least, there was a bug in getFromCache() and the cache size was increased from 2 MB to 4 MB. (I picked 2 MB mainly because it allowed me to quickly get to the point where it would have to throw away cached resources.)
I knew SylvainTV had been looking at it (which is how I knew about the bug I had made), but I didn't notice it had been committed until now.
See commit 6873e9673213516539acca37c08b1d6c0bfaa350.
comment:4 by , 14 years ago
Status: | new → closed |
---|
comment:5 by , 6 years ago
Component: | → Engine: Toon |
---|
comment:6 by , 5 years ago
Game: | → Toonstruck |
---|
Patch against current Git trunk