Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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  
  Checking for memory problems with long runs ...  (Read 1590 times)
0 Members and 1 Guest are viewing this topic.
Offline Evanstaul

Senior Newbie





« Posted 2005-08-09 15:31:08 »

Probably the way I'm doing this is the wrong approach.  I let my game run for a a long time, maybe run it while I'm going to work, to see if it'll crash when I get back.  Sometimes I find that it crashes within a few hours.  Then I'll know to adjust the heap size or put some =null in places.  Does anyone test like this or am I the only one?  Is there a better equivalent method?

Thanks!
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2005-08-10 02:28:07 »

If youa re getting a crash after a long run then it means you have an object leak-- one or mreor eferences to obejcst that you should be cleaning up that you aren't.

The best way to find these is with a decent Java profiler.  With a profiuler yo ushouldnt have to run all that long, runa few minutes then break and inspect your heap to see what objects are still alive and why.

But really if you are running into such errors it means youa re doing soemthign VERY wrong. As you get more exprience with Java you should rarely to never see such problems.   Thats why we have a garbage colelctor after all.

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 Linuxhippy

Senior Member


Medals: 1


Java games rock!


« Reply #2 - Posted 2005-08-10 14:06:40 »

Well I use tools like profilers to find memory leaks since just let it running for very long and wait until a crash inst really reliable.

However I have leaks only very, very seldom ... I am (especially when writing server software) a lot more scared about it than I would need to be ... however better waste some hours beeing scared than breaking down some companies buissness ;-)

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

JGO Coder




Where's the Kaboom?


« Reply #3 - Posted 2005-08-11 05:33:38 »

If youa re getting a crash after a long run then it means you have an object leak-- one or mreor eferences to obejcst that you should be cleaning up that you aren't.

Actually it depends very much on the nature of the crash.  If you get an OutOfMemory condition the VM will report it as one.  If the game locks-up, then it is usually graphics drivers or Java's use of DirectX/OpenGL.
If you get a application fault - it is a bug  in the VM or if you are using JNI libs like JOGL or LWJGL it could be them.

I have found that there are serious bugs in the JVM that will cause a hard crash on long-term tests.  Possibly related to the GC algorithm that you choose.  It is difficult to isolate, but it was introduced after 1.5.0_01.

Offline Jeff

JGO Coder




Got any cats?


« Reply #4 - Posted 2005-08-12 06:35:15 »

Good points by SWP.

If you have any native code, you COUDL also be leaking memory there.  Thats not something a Java profiler will show you.

In general, the more used a  native library is, the moe likely it is that leakes have been found and fixed but its no
gaurantee.

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 anarchotron

Junior Member




...precious bodily fluids.


« Reply #5 - Posted 2005-08-12 17:38:25 »

I suppose if you want to track down native leaks, you might want to

1. ensure that every native resource allocated is owned by some java object
2. give that object some kind of unloadResources() method
3. in the finalize() method, simply check to see if the resources have been unloaded and emit a warning or exception

Relying on finalize() for native cleanup is pretty sloppy, so I would just use it as a last-check to find java objects that are getting GC'd without having released their resources.
Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2005-08-13 06:39:22 »


Relying on finalize() for native cleanup is pretty sloppy,

Its more then sloppy, its not gauranteed to work.  The finalizer gets called when the object is actually collected. There is no gaurantee when if ever an object will be collected.

Over-user of finalizers can also give you GC problems as it forces obejcts to persist beyonf the eden-space regardless of their actual lifetime.

Finalizers are bad news and really a deprecated feature.  If you really need post-mortem cleanup then PhantomReferences are nominally better though even there there are no gaurantees of execution and they suffer similar GC issues.

In terms of finding native leaks there are some natvie tools you could run the VM process under to find them, such as Purify, but they arent cheap.



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 swpalmer

JGO Coder




Where's the Kaboom?


« Reply #7 - Posted 2005-08-17 03:53:04 »

In terms of finding native leaks there are some natvie tools you could run the VM process under to find them, such as Purify, but they arent cheap.
I think you can get a free 30-fay eval of Compuware's Bounds Checker which might help.

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.

pw (24 views)
2014-07-24 01:59:36

Riven (24 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (54 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
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!