Resource Loading manager. Onto memory or not?
#1 Members - Reputation: 110
Posted 16 August 2012 - 02:36 PM
I've also done pretty much the same for my audioResourceLoading manager.
Now what I'm thinking of implementing down the road is that the imageLoading manager only holds image files that are under a certain size or animations (other things like static backgrounds can be reloaded if needed).
And as for the audio, if its sound effects its pre-loaded onto a clip and therefore its held in memory. But for large audio files like background music, I'm thinking of maybe streaming it and buffering it so that its played as its loaded, with a sourceDataLine.
One thing I'm wondering is, I know when i load an image and an instance is presenting it on the screen (using it as representation), its being held in memory. Now if I'm putting a copy of it in a hashmap will that copy be in memory as well? or is it using the same memory space as the first one that was loaded? Same goes for when I create other instances that use this same image as a representation. Does anyone know?
And yes I know tools like Slick2D handle all this resource loading stuff for you (or so I've read), but I'm mostly doing it for the learning experience. For example to get that audioLoader going I learned a great deal of the sound API.
So yeah, just wanna hear some thoughts on this. ;D
#2 Members - Reputation: 429
Posted 17 August 2012 - 06:28 AM
Also, I go about my resource loading in a different way. I like to have a completely generic loading backend, when possible, that loads files from some source (generally the filesystem, but could be the network, or an archive) and puts them into memory as a blob. Then, I pass that blob off the particular subsystem to be decoded and whatnot. This way, you don't end up duplicating your file loading logic. Loading images, loading audio, loading models, etc. are all the same at the most basic level.
#3 Members - Reputation: 110
Posted 17 August 2012 - 09:47 PM
If your resource loader is returning the images/audio from the hash map by reference, then your instance is using the SAME copy and taking up no additional memory (except the size of a pointer/reference.) However, for images, if you're rendering with hardware, then you are also necessarily holding a copy of the image in video memory.
Also, I go about my resource loading in a different way. I like to have a completely generic loading backend, when possible, that loads files from some source (generally the filesystem, but could be the network, or an archive) and puts them into memory as a blob. Then, I pass that blob off the particular subsystem to be decoded and whatnot. This way, you don't end up duplicating your file loading logic. Loading images, loading audio, loading models, etc. are all the same at the most basic level.
Great, thanks for resolving that inquiry of mine. And thanks for the tip there. I'll work on abstracting my file loading logic a bit more so that I could go at the same you do. Thanks






