Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another dumb memory question



This code will add a new object (a MouseAdapter instance) each time a
new MouseListener is added. (Each time addMouseListener() is called,
not each time mouseClicked() is called.) And of course you want one
instance for each call to addMouseListener(). No memory issue.

-Ian

On Thursday, Aug 15, 2002, at 18:11 US/Pacific, Craig A. Mattocks wrote:

> If I use an anonymous inner class in an Applet to listen for mouse
> clicks:
>
> addMouseListener
> (
> new MouseAdapter()
> {
> public void mouseClicked( MouseEvent e )
> {
> // Do stuff
> }
> }
> );
>
> Will this generate objects each time the mouse is clicked? If so,
> could this eat a significant amount of memory in a fast-paced action
> game -- lots of mouse clicks in a thread with little chance for gc()?
>
> Apologies in advance for my inane questions,
> - Craig
> _______________________________________________
> java-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/java-dev
> Be sure to read the FAQ http://developer.apple.com/java/faq/ before
> posting
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Another dumb memory question (From: "Craig A. Mattocks" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.