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: StackOverflowError



On Wed, 27 Jul 2005, Bjorn Roche wrote:

Hey all,

I have a complex swing app. I am having a problem where occationally the program gets a StackOverflowError. The stack traces are really long, but I've put a snippet below.

Now, I know full well that I can increase the java stack size (I have managed to make them more common by reducing the size), but considering that most of the stack trace lies in AWTEventMulticaster and never even hits my code, I am concerned that this is a bug in AWT or apple's code. From looking at the AWTEventMulticaster javadocs, it appears that AWTEventMulticaster uses a binary-tree type structure to multicast events. Is that right? If so, am I doing something wrong in my code to cause so much multicasting? Do I need to start unregistering event listeners from deleted objects or something?

Maybe someone else has experience with something simmilar? Is there a simple tip, like running the garbage collector more often (I've tried that)?

Bottom line is I want to make sure I fix my problem rather than, eg, pushing it back until my program has been up and running longer.


Someone replied to me off list saying that it looked like an infinite recursion to him. Thanks for the reply! I thought so too, at first, but now I actually don't think so. If it were a infinite recursion, the event (a simple mouse gesture, usually) would always cause stack overflows regardless of the stack size. In fact, when I decrease my stack size I get more stack overflows, and I get fewer with a larger stack. So I think all those java.awt.AWTEventMulticaster.mouseExited(AWTEventMulticaster.java:251) calls in my stack trace are on *different* objects traversing through a tree-like structure.


This javaworld article explains a bit about the AWTEventMulticaster. I haven't seen anything better for that purpose:

http://www.javaworld.com/javaworld/jw-03-1999/jw-03-toolbox-p3.html

It seems that a large stack is a natural consequence of the model used for event multicasting. (the article says "You'll note in Figure 1 that the tree will most likely degrade into a linked list, and recursive traversal of a linked list can use up a lot of runtime stack.")

What I don't understand is: what are all those event listeners, and how can I have fewer of them? Bottom line: is there anything I can do to limit the size of of the EventMulticaster, or do I really just have to increase my stack size and hope to God I don't overflow when the user opens up 1 more window than what I tested?

As always, any suggestions are appreciated!

	bjorn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >StackOverflowError (From: Bjorn Roche <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.