Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Makin' a game in Java


  • Please log in to reply

#1
ACher91

ACher91

    Member

  • Member
  • PipPip
  • 98 posts
Yes, yes, don't laugh, I'm programming a game in Java. (In Gridworld. :) )

I've been working at it for about close to a year now, but it's finally developed a severe limitation—OutOfMemoryError. :) Due to all the sound I play during the game, eventually the memory runs out and it gets runtime errors and stops functioning... Of course, I COULD just catch the OutOfMemoryError, which I actually used to do as a temporary solution, but that would mean it can't play any sound past the out of memory point, and that would defeat the entire purpose. What I need is some way to renew or replenish the memory entirely, which doesn't seem to be possible...

I'm using Runtime.getRuntime().getMaxMemory() - Runtime.getRuntime().getTotalMemory() to see how much memory is actually left, and it drops every time a certain amount of sounds are played, so I know for sure that this is the problem. Also, if I try explicitly running the garbage collector with System.gc(), it actually LOWERS the memory for some reason. :)

I've also tried closing the gridworld window, saving the entire game as it was at that point, reopening a new window, and repopulating everything, but I quickly found that that wouldn't work either, as it's still the same program, and thus the same Runtime, and thus, the same memory... :)

Anybody know any way to get around this? There's gotta be some way to make this work; I mean, how do massive games like Age of Empires, that you can keep opened for several hours and that constantly play thousands of sounds do it? My wimpy little program that just opens a gridworld window causes my computer to run out of memory, jeez....
  • 0

Advertisements


#2
Ryan_88

Ryan_88

    Member

  • Member
  • PipPipPip
  • 110 posts
how much RAM does the machine you're running it on have?
  • 0

#3
ACher91

ACher91

    Member

  • Topic Starter
  • Member
  • PipPip
  • 98 posts
1 GB
  • 0

#4
Ryan_88

Ryan_88

    Member

  • Member
  • PipPipPip
  • 110 posts
got another question, what are the audio files encoded as? their file size and type will have a direct impact on memory and performance
  • 0

#5
ACher91

ACher91

    Member

  • Topic Starter
  • Member
  • PipPip
  • 98 posts
they are .wavs

Mostly, the sounds in question are about 60KB. They are meant to play every time you attack (sword slash, bow, etc). I also have songs, which are quite massive... OVER NINE THOUSAAAAAAAAAND kb. But they do not start and stop constantly, they are just background music. :)

Edited by ACher91, 12 December 2009 - 08:05 PM.

  • 0

#6
presentfactory

presentfactory

    New Member

  • Member
  • Pip
  • 5 posts

they are .wavs

Mostly, the sounds in question are about 60KB. They are meant to play every time you attack (sword slash, bow, etc). I also have songs, which are quite massive... OVER NINE THOUSAAAAAAAAAND kb. But they do not start and stop constantly, they are just background music. :)


I think that some types of compressed mp3 files can be smaller. Here are valid aduio extentions and thier popularity :) :

.4mp 4-MP3 Database File Average
.669 UNIS Composer 669 Module Average
.6cm Six Channel Module Average
.8cm Eight Channel Module Average
.8med Amiga OctaMed Music File Average
.8svx Amiga 8-Bit Sound File Average
.a2m AdLib Tracker 2 File Average
.aa Audible Audio Book File Average
.aa3 ATRAC Audio File Common
.aac Advanced Audio Coding File Very Common
.aax Audible Enhanced Audiobook File Average
.abc ABC Music Notation Average
.abm Music Album Average
.ac3 Audio Codec 3 File Average
.acd ACID Project File Average
.act ADPCM Compressed Audio File Average
.adg Ableton Device Group Average
.agm DTS Multi-channel Pro Packer File Average
.ahx WinAHX Tracker Module Average
.aif Audio Interchange File Format Very Common
.aifc Compressed Audio Interchange File Average
.aiff Audio Interchange File Format Average
.ais Velvet Studio Instrument Average
.akp Akai Sampler File Average
.al A-Law Compressed Sound Format Average
.alaw A-Law Compressed Sound Format Average
.all Cubasis Project File Average
.amf Advanced Module File Average
.amr Adaptive Multi-Rate Codec File Average
.ams Extreme Tracker Module Average
.ams Velvet Studio Module Average
.aob DVD-Audio Audio Object File Average
.ape Monkey's Audio Lossless Audio File Average
.ase Velvet Studio Sample Average
.atrac Sony ATRAC Audio File Rare
.au Audio File Average
.aud Video Game Compressed Audio File Average
.aup Audacity Project File Average
.avr Audio Visual Research File Average
.awb AMR-WB Audio File Uncommon
.band GarageBand Project File Average
.bap Blaze Audio Wave Information File Average
.bdd CARA Sound Radiation Data File Average
.box CARA Loudspeaker Design File Average
.bun Cakewalk Bundle File Average
.bwf Broadcast Wave File Average
.c01 Typhoon Wave Audio File Average
.caf Core Audio File Common
.cda CD Audio Track Shortcut Average
.cdr Raw Audio CD Data Average
.cel Audition Loop Average
.cidb iTunes CD Information File Average
.cmf Creative Music Format Uncommon
.copy Sony Ericsson Protected Content File Average
.cpr Cubase Project Common
.cpt DTS Compact Audio File Average
.csh Cubase Waveform File Average
.cwp Cakewalk SONAR Project Average
.d00 OPL2 FM Audio File Average
.d01 OPL2 FM Audio File Average
.dcf DRM Content Format File Average
.dcm DCM Audio Module Average
.dct Dictation Audio File Average
.dewf SoundEdit Recorded Instrument Average
.df2 Defractor 2 Instrument Average
.dfc Defractor Instrument Average
.dig Digilink Audio File Average
.dig Sound Designer Audio File Average
.dls Downloadable Sounds File Average
.dm DRM Delivery Message Average
.dmf Delusion Digital Music File Average
.dsf Delusion Digital Sound File Average
.dsm Digital Sound Module Average
.dsp Dynamic Studio Professional Module Average
.dss Digital Speech Standard File Common
.dtm DigiTrakker Module Average
.dts DTS Encoded Audio File Average
.dtshd DTS-HD Master Audio File Average
.dvf Sony Digital Voice File Average
.dwd DiamondWare Digital Audio File Average
.ear Eyemail Audio Recording Average
.efa Ensoniq ASR File Average
.efe Ensoniq EPS File Average
.efk Ensoniq KT File Average
.efq Ensoniq SQ1/SQ2/KS-32 File Average
.efs Ensoniq SQ-80 File Average
.efv Ensoniq VFX-SD File Average
.emd ABT Extended Module Average
.emp eMusic Playlist File Common
.emx eMusic Download File Common
.esps ESPS Sampled Data File Average
.f2r Farandoyle Linear Module File Average
.f32 Raw 32-Bit Audio File Average
.f3r Farandoyle Blocked Module File Average
.f64 Raw 64-Bit Audio File Average
.far Farandole Composer Module Average
.fff Gravis UltraSound Sound Bank Average
.flac Free Lossless Audio Codec File Common
.flp FruityLoops Project Average
.fls Flash Lite Sound Bundle Uncommon
.fsm Farandole Composer WaveSample File Average
.fzb Casio FZ-1 Bank Dump Average
.fzf Casio FZ-1 Full Dump Average
.fzv Casio FZ-1 Voice Dump Average
.g721 G.721 Audio File Average
.g723 G.723 Audio File Average
.g726 G.726 Audio File Average
.gig Tascam GigaSampler File Average
.gp5 Guitar Pro 5 Tablature File Average
.gpk WaveLab Audio Peak File Average
.gsm Global System for Mobile Audio File Average
.gsm US Robotics GSM Audio File Average
.ics IC Recorder Sound File Average
.iff Interchange File Format Very Common
.ins Ensoniq Instrument Average
.ins Sample Cell II Instrument Definition File Average
.it Impulse Tracker Module Uncommon
.iti Impulse Tracker Instrument Average
.its Impulse Tracker Sample Average
.jam JAM Musical Score Average
.k25 Kurzweil K2500 File Average
.k26 Kurzweil K2600 File Average
.kar Karaoke MIDI File Average
.kin Kinetic Music Project Average
.kit Battery Drum Kit File Uncommon
.kmp Korg Trinity/Triton Keymap File Uncommon
.koz Audiokoz Music File Average
.koz Bell Music File Average
.krz Kurzweil K2000 File Average
.ksc Korg Trinity/Triton Script File Uncommon
.ksf Korg Trinity/Triton Sample File Average
.kt2 Battery 2 Drum Kit File Uncommon
.kt3 Battery 3 Drum Kit File Average
.ktp Kinetic Project Template Average
.l Left Audio Channel File Average
.la Lossless Audio File Average
.lqt Liquid Audio File Uncommon
.lso Logic Audio Project Average
.lvp Avaya Voice Player Audio File Uncommon
.lwv Linguistically Enhanced Sound File Average
.m1a MPEG-1 Audio File Uncommon
.m3u Media Playlist File Very Common
.m4a Apple Lossless Audio File Common
.m4b MPEG-4 Audio Book File Common
.m4p iTunes Music Store Audio File Average
.m4r iPhone Ringtone File Common
.ma1 Monarch Audio File Average
.mdl DigiTrakker Module Average
.med Amiga MED Sound File Average
.mgv Yamaha MegaVoice File Average
.mid MIDI File Very Common
.midi MIDI File Very Common
.miniusf Nintendo 64 Song File Average
.mka Matroska Audio File Average
.mlp Meridian Lossless Packing Audio File Uncommon
.mmf Synthetic Music Mobile Application File Average
.mmm MAGIX Music Maker File Uncommon
.mo3 MO3 Audio File Average
.mod Amiga Music Module File Common
.mp1 MPEG-1 Layer 1 Audio File Uncommon
.mp2 MPEG Layer II Compressed Audio File Average
.mp3 MP3 Audio File Very Common
.mpa MPEG-2 Audio File Very Common
.mpc Musepack Compressed Audio File Average
.mpd File List Creator Playlist Average
.mpga MPEG-1 Layer 3 Audio File Average
.mpu MPEG Layer 3 Audio File Average
.mp_ Mobile Phone Sound File Average
.msv Memory Stick Voice File Uncommon
.mt2 MadTracker 2 Module Uncommon
.mte MadTracker 2 Envelope Average
.mti MadTracker Instrument Average
.mtm MultiTracker Module Average
.mtp MadTracker 2 Pattern Average
.mts MadTracker 2 Sample File Average
.mus Finale Notation File Format Average
.mws MWave DSP Synth Instrument Extract Rare
.mzp Mozart Percussion File Uncommon
.nap Napster Secured Music File Average
.nki KONTAKT Instrument File Average
.nra Nero Audio Compilation Average
.nrt Nokia Ringtone Average
.nsa Nullsoft Streaming Audio File Average
.nsf NES Sound Format File Average
.nst NoiseTracker Module Average
.ntn NOTION Song File Average
.nwc NoteWorthy Composer File Average
.odm OverDrive Media File Average
.oga Ogg Vorbis Audio File Average
.ogg Ogg Vorbis Compressed Audio File Common
.okt Oktalyzer Module Average
.oma Sony OpenMG Music File Average
.omf Open Media Framework File Average
.omg OpenMG Audio File Average
.omx OtsAV Media Library Information File Average
.ots OtsAV Album File Average
.ove Overture Musical Score Average
.pac SBStudio II Song File Average
.pat Gravis UltraSound GF1 Patch File Average
.pbf Pinnacle Sample Bank Average
.pca Perfect Clarity Audio Average
.pcg Korg Instrument Bank File Average
.pcm Pulse Code Modulation Average
.peak Steinberg Peak File Average
.phy PhyMod Physical Modeling Data Average
.pk Audition Peak File Average
.pla Sansa Playlist File Average
.pls Audio Playlist Average
.pna PhatNoise Audio File Average
.prg WAVmaker Program File Average
.prg Akai MPC2000 Program File Average
.psf Portable Sound File Average
.psm Protracker Studio Module Average
.ptf Pro Tools 7 Session File Common
.ptm PolyTracker Module Average
.pts Pro Tools Session Average
.pvc Panasonic VM1 Voice File Average
.qcp PureVoice Audio File Average
.r Right Audio Channel File Uncommon
.r1m RealOne Streaming Media File Average
.ra Real Audio File Very Common
.ram Real Audio Media Common
.raw Raw Audio Data Average
.rbs Rebirth Song File Average
.rex ReCycle Loop File Average
.rfl Reason ReFill Sound Bank Average
.rmf Rich Music Format Average
.rmi RMID MIDI File Average
.rmj Real Media Jukebox Audio File Average
.rmm RAM Meta File Uncommon
.rmx RealJukebox Format Average
.rng Nokia Composer Ringtone Average
.rns Reason Song File Common
.rol Ad Lib Synthesized Instrument Average
.rsn Reason Project File Average
.rso NXT Brick Audio File Average
.rti Real Tracker Instrument Average
.rtm Real Tracker Module Average
.rts Real Tracker Sample Average
.s3i Scream Tracker 3 Instrument Average
.s3m ScreamTracker 3 Module Uncommon
.saf Secure Audio File Average
.sam MOD Edit Sample File Average
.sb Signed Byte Audio File Rare
.sbi Sound Blaster Instrument Average
.sbk E-MU SoundFont Sound Bank Uncommon
.sc2 Sample Cell II Instrument Definition Average
.sd Sound Designer Audio File Average
.sd ESPS Sampled Data File Average
.sd2 Sound Designer II File Average
.sds MIDI Sample Dump Standard File Average
.sdx Sample MIDI Dump Exchange Average
.ses Audition Session Average
.sf IRCAM Sound File Average
.sf2 SoundFont 2 Sound Bank Average
.sfk Sound Forge Audio Peak File Average
.sfl Sound Forge Sound Data File Average
.shn Shorten Compressed Audio File Average
.sib Sibelius Score Common
.sid Commodore 64 Music File Average
.sid SID Audio File Average
.smf Standard MIDI File Average
.smp SampleVision Audio Sample Format Average
.snd Sound File Common
.snd Macintosh Sound Resource Average
.snd Akai MPC Sample Uncommon
.sng MIDI Song File Average
.sou SBStudio II Sound File Average
.sppack SPPack Sound Sample Average
.sprg Synclavier Program File Average
.sseq Synclavier Sequence File Average
.ssnd Synclavier Sound File Average
.stm Scream Tracker 2 Module Average
.stx Scream Tracker Music Interface Kit File Average
.sty Yamaha/Korg Keyboard Style Uncommon
.svx 8SVX Sound File Average
.sw Signed Word Audio File Average
.swa ShockWave Audio Average
.syh Synchomatic Instrument Average
.syw Yamaha SY99/SY85 Audio File Average
.syx MIDI System Exclusive Message Average
.td0 Akai Teledisk Sound Library Average
.tfmx Final Music System Tracker Module Average
.thx Amiga THX Tracker Music File Average
.toc PSP Audio File Average
.tsp TrueSpeech Audio File Average
.txw Yamaha TX16W Audio File Average
.u AU Audio File Average
.ub Unsigned Byte Audio File Uncommon
.ulaw Raw u-Law Audio File Uncommon
.ult UltraTracker Module Average
.ulw u-Law Audio File Rare
.uni MikMod UniMOD Module Average
.usf Nintendo 64 Music File Average
.usflib Nintendo 64 Song Library Average
.uw Unsigned Word Audio File Average
.uwf UltraTracker Wave File Average
.vag PlayStation Compressed Sound File Average
.val Olympus Voice Recording Rare
.vc3 VSampler Soundbank File Average
.vmd Covox Raw Sample Average
.vmf Vocaltec Media File Average
.vmf Covox Speech Thing Sample Average
.voc Creative Labs Audio File Average
.voi Voyetra Voice File Average
.vox VoxWare Dialogic Audio File Average
.vpl Karaoke Player Playlist Average
.vqf TwinVQ Audio File Average
.vrf Ventrilo Audio Recording Average
.vyf Samsung Digital Voice Recorder File Average
.w01 Yamaha SY Series Wave File Average
.wav WAVE Audio File Very Common
.wav DTS-WAV File Uncommon
.wave WAVE Sound File Average
.wax Windows Media Audio Redirect Average
.wfb WaveFront Sound Bank Average
.wfd WaveFront Drum Kit File Average
.wfp WaveFront Program File Average
.wma Windows Media Audio File Very Common
.wow Grave Composer Music Module Average
.wpk Nero Wave Editor File Average
.wproj Wwise Project Average
.wrk Cakewalk Music Project Average
.wus WUTG Tagged Audio File Average
.wut WUTG Tag File Average
.wv WavPack Audio File Average
.wvc WavPack Correction File Average
.wwu Wwise Work Unit Average
.xfs eRacer Sound File Average
.xi Fasttracker 2 Extended Instrument File Average
.xm Fasttracker 2 Extended Module Average
.xmf Extensible Music File Average
.xmi Extended MIDI File Average
.xmz FastTracker 2 Extended Module Uncommon
.xp Fastracker 2 Pattern Average
.xrns Renoise Song File Average
.xsb XACT Sound Bank Uncommon
.xspf XSPF Playlist File Average
.xt Fastracker 2 Track Average
.xwb XACT Wave Bank Uncommon
.zvd ZyXEL Voice File Average
.zvr SAFA Media Audio File Rare
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP