• Post Reply Bookmark Topic Watch Topic
  • New Topic

Macs, Windows, and Memory Leaks  RSS feed

 
Edward Nunez
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, I have a bit of an issue here.

I have my Java game but it takes up way too much memory. Oddly, the problem really only exists on Mac OS. It bamboozles extra memory at a rate of 1 gig/minuet, seems like a lot of memory for a Breakout variant. I used Visual VM to compare heap dumps of the game running on both platforms and noticed that Mac OSX instantiates an enormous amount of objects of type sun.lwawt.macosx.event.NSEvent. Windows didn't instantiate anything like this/nearly as much as this.

I think this class has something to do with my listener methods. A little about my game: The main class, Game, implements KeyListener, MouseListener, MouseMotionListener. I listen for a key strike to pause the game, mouse click to start the game, and mouse motion to control the game paddle. Anyhow, I noticed that when I stripped my mouseMouved(MouseEvent e) method of definition, far fewer of the NSEvent class were instantiated. So, I feel like I'm doing something wrong with my event methods.

That's where I am at the moment. If anybody's ever heard of the NSEvent class or has any advice for me please let me know.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edward Nunez wrote:
That's where I am at the moment. If anybody's ever heard of the NSEvent class or has any advice for me please let me know.

No idea. But check out http://cr.openjdk.java.net/~serb/7124543/webrev.00/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java.cdiff.html

In your code, what do you do on mouseMoved()?
 
Edward Nunez
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh Godbole wrote:
Edward Nunez wrote:
That's where I am at the moment. If anybody's ever heard of the NSEvent class or has any advice for me please let me know.

No idea. But check out http://cr.openjdk.java.net/~serb/7124543/webrev.00/src/macosx/classes/sun/lwawt/macosx/event/NSEvent.java.cdiff.html

In your code, what do you do on mouseMoved()?


I'll have to inspect that a bit.

There isn't much code in that method. Take a look:


PaddleList has two paddles, separated on the x-axis by the width of the panel. This and and another method create a wrap-around effect.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!