Jump to content
  • Advertisement
Sign in to follow this  
BrianJensen

[JAVA] Image & AudioClip

This topic is 2116 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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; ........

Edited by 0Circle0

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!