[JAVA] Image & AudioClip

Started by
1 comment, last by BrianJensen 11 years, 4 months ago

when you load a resource do you have to then remove it? and if so how?

Click = getAudioClip(this.getClass().getResource("/Sprites/Audio/click.wav"));
BlackPiece = getImage(this.getClass().getResource("/Sprites/BlackPiece.png")); ....... private AudioClip Click; private Image BlackPiece; ........

Sprite Creator 3 VX & XP

WARNING: I edit my posts constantly.

Advertisement
Java is a high-level programming language, and therefore does a lot of management for you in its virtual machine (JVM). One such thing is a garbage-collecting system. Once the JVM's garbage collector detects that your variable isn't being used anymore, it frees up that area in memory. So your short answer for that is no.
If you're concerned about using space however, you can model your objects in a way that removes references when they're "destroyed," prompting the garbage collector to remove them. If you know you're going to have multiples of that same class being displayed, it may also be a good idea to make your Images and AudioClips static, so you only need to instantiate one, rather than create a new one for every instance.

Thanks for the info

Sprite Creator 3 VX & XP

WARNING: I edit my posts constantly.

This topic is closed to new replies.

Advertisement