My game precaches animations and hidden it in splash screen while precaching it. And it takes up to 300mb.
The good thing is whenever I want to play animation, there is no noticable lag / frameskip while playing the animation
I'm looking at the Cache module and I see that when an image is loaded, it gets stored in a hash.
However, does it ever get deleted when it's no longer needed? Or do all images just get cached forever until you restart the game (at which point the cache is cleared and GC'd)?
By "no longer needed" I mean it hasn't been accessed for a sufficiently long time.
Some of the images are disposed. Look at how draw_face at the Window_Base
def draw_face(face_name, face_index, x, y, enabled = true) bitmap = Cache.face(face_name) rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96) contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha) bitmap.dispose # <-- This line dispose the cached faceset endIt's actually depends on how the script handled the bitmap. Some of them get disposed, some may not.
The interesting thing from bitmap is if you lose the variable that referenced to the bitmap, it get disposed instantly, unlike Sprite / Window / Plane / Viewport
Look at how cache get cleared
def self.clear @cache ||= {} @cache.clear GC.start endThough, honestly I'm not sure if it was because GC.start.