Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (105)
games submitted by our members
Games in WIP (524)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Little Pauses  (Read 2067 times)
0 Members and 1 Guest are viewing this topic.
Offline drewlane

Senior Newbie




I am the Walrus!


« Posted 2003-08-07 16:46:57 »

I recently wrote a little bowling game in Java.

I tried really hard to reuse my objects and avoid the new keyword.

However, sometimes (not all the time, mind you) I still get this little pause before the ball hits the pins.  

I'm calling the garbage collector in between frames but I still see these little pauses every once in a while - very annoying!

How do I figure out what is causing this exactly?  I don't have much experience with profilers, etc.

Thanks,

Drew

Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #1 - Posted 2003-08-07 16:58:43 »

Don't be overly afraid to use the new keyword, it's not Evil.

Don't call System.gc() manually.


And I'm willing to bet a lot of money that the pause is when the ball hits, not just before. Starting any sounds, or  doing any  massive amounts of physics?

Play Minecraft!
Offline drewlane

Senior Newbie




I am the Walrus!


« Reply #2 - Posted 2003-08-07 17:06:02 »

Yes, there is a sound effect, I think that might be it.  I just took it out and it helped.

It's just an AudioClip class from Java 1.1 Applet package and I'm using the standard play() method.

Is there a better way to handle sound effects?  I need to stick with Java 1.1, however.

Drew
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #3 - Posted 2003-08-07 17:14:22 »

Aaahh!! *hides from the evil ms vm*

Play Minecraft!
Offline drewlane

Senior Newbie




I am the Walrus!


« Reply #4 - Posted 2003-08-07 20:15:01 »

Grrrr!

Well, it's definetly the sound effects causing most of the pauses.  

The only thing I can think is to remove the sound effects, but that's a pretty lame solution.  Cry

I guess I could put a toggle switch on it and let the user decide...

However, even after I removed all the sounds, there is one other little pause that comes when a sprite is rapidly changing directions.  Not sure what is causing this one yet.   Huh

Drew


Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #5 - Posted 2003-08-08 15:17:37 »

It's a strange phenomenom that whenever a Java program isn't smooth or performs bad, the GC is accused.  Roll Eyes

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2003-08-09 06:41:56 »

Quote

However, even after I removed all the sounds, there is one other little pause that comes when a sprite is rapidly changing directions.  Not sure what is causing this one yet.   Huh


Hmm, well if you can get your hands  on a Profiler it might help you track it down.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Herkules

Senior Member




Friendly fire isn't friendly!


« Reply #7 - Posted 2003-08-09 10:43:27 »

Hm hm, small pauses here and then are hard to detect with a profiler?

HARDCODE    --     DRTS/FlyingGuns/JPilot/JXInput  --    skype me: joerg.plewe
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #8 - Posted 2003-08-11 08:49:25 »

On what VM do you experience these pauses?
For example I experienced when you use a lot of memory in the MS VM, the GC will go nuts and cause a lot of little pauses. The Sun VM seems a lot better at this.

On the Sun VM you can use the -Xprof switch to profile and the -Xloggc:<file> switch to log the GC activity. If that log shows a lot of 'full gc' reports that take some time (and also when the pauses occur), then it's probably caused by the GC.
If it's an applet, use the appletviewer and the -J switch to pass the above switches to the VM.

Offline MGodehardt

Junior Member




why does the chicken cross the road?


« Reply #9 - Posted 2003-09-11 08:58:06 »

Try to increase the number of backbuffers, i used 2 buffers and got a FPS slowdown when my render loop was running too fast ( strange but when i inserted some drawImage loops my FPS increased ).

Then i switched from 2 to 4 Buffers and it solved a lot of problems  Cool
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline caraiz

Senior Newbie




Java games rock!


« Reply #10 - Posted 2003-09-11 10:47:51 »

Quote
Yes, there is a sound effect, I think that might be it.  I just took it out and it helped.

It's just an AudioClip class from Java 1.1 Applet package and I'm using the standard play() method.

Is there a better way to handle sound effects?  I need to stick with Java 1.1, however.

Drew


I suppose u use Applet.getAudioClip(url) and then play().
I had the same problem, and i think i was cause it have to load the data everytime u want get the audioclip.

U can use classes of the package sun.audio (no standard, but maybe it can help u). In AudioPlayer u can specify a InputStream, so u can load the data of the audioclip in an array of bytes, and then use this array in a class of this package which extends of InputStream.

Sorry, but I have no the code here, so this is that i remember of it.... If u wish try to search documentation about the package sun.audio

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

quew8 (13 views)
2014-07-13 13:57:52

SHC (38 views)
2014-07-12 17:50:04

Riven (33 views)
2014-07-10 20:20:18

CopyableCougar4 (34 views)
2014-07-10 02:26:14

CopyableCougar4 (36 views)
2014-07-09 02:55:38

Code Mage (35 views)
2014-07-08 23:57:00

Code Mage (25 views)
2014-07-08 23:49:08

AppleSauce (29 views)
2014-07-08 19:25:32

CopyableCougar4 (31 views)
2014-07-06 01:51:26

ipe369 (39 views)
2014-07-05 14:18:25
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!