Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
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  
  graphics obj during rendering  (Read 1324 times)
0 Members and 1 Guest are viewing this topic.
Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Posted 2004-04-10 17:08:49 »

I was just thinking about this in terms of garabge collection. In my rendering loop I have a
Graphics g = bs.getDrawGraphics();
and then later
g.dispose();
So each render I crate and dispose of the graphics object. Is this a proper way of rendering? Wouldn't the constant creation and disposing of the object trigger the gabage collection at a bad time?

Kommi
Offline kevglass

JGO Kernel


Medals: 122
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #1 - Posted 2004-04-10 17:13:07 »

bs.getDrawGraphics() doesn't nessersaryly create a graphics object. In the same way g.dispose() doesn't mean that the graphics object would be destroyed and garbaged collected.

Kev

Offline D.t.O

Junior Member




Psych'd about Java Games


« Reply #2 - Posted 2004-04-10 20:36:14 »

Is there any way to more or less label an object so that you can be sure it will be garbage collected on the next run of the garbage collector?

Enjoy.
Regards,
     - D.t.O
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2004-04-10 21:20:57 »

Absolutely not.

GC is always at the dsicretion of the VM. It has to be to allow for efficient gc algortihyms.

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 D.t.O

Junior Member




Psych'd about Java Games


« Reply #4 - Posted 2004-04-10 23:12:08 »

dang. oh well. Sad

Thanks for the info though.

Enjoy.
Regards,
     - D.t.O
Offline cfmdobbie

Senior Member


Medals: 1


Who, me?


« Reply #5 - Posted 2004-04-13 21:41:16 »

If the object is short-lived, the VM will notice and make special considerations for it.  You shouldn't get any GC pause from short-lived objects with a modern VM.

When starting programming in Java, the first rule of memory management is just not to think about it - a number of very intelligent engineers have designed the VM such that you shouldn't have to.

Hellomynameis Charlie Dobbie.
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #6 - Posted 2004-04-14 04:13:02 »

A note: a Graphics object is a graphics context and is pretty lightweight as such, it just holds a state.

It's better to obtain a new graphics context every time, and then dispose of it.

Offline D.t.O

Junior Member




Psych'd about Java Games


« Reply #7 - Posted 2004-04-14 04:24:15 »

When you call foo.getDrawGraphics() twice, do you get two separately allocated Graphics objects, or just one object that is returned twice? Is this behavior constant, i.e. do you always get the same behavior?

Enjoy.
Regards,
     - D.t.O
Offline Jeff

JGO Coder




Got any cats?


« Reply #8 - Posted 2004-04-14 04:27:25 »

Unless it says soemthing specific in the Java doc that woudl be VM dependant.

Anything not in the JavaDocs is VM dependant by definition Wink

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 D.t.O

Junior Member




Psych'd about Java Games


« Reply #9 - Posted 2004-04-14 04:31:58 »

I edited my post while you were writing, but I guess you answered the second question too Grin
Thanks Smiley

Enjoy.
Regards,
     - D.t.O
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.

CogWheelz (16 views)
2014-07-30 21:08:39

Riven (22 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

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

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

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

Riven (31 views)
2014-07-23 20:56:16
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!