Oooooo... I bet that¹s it!! When memory gets low, the entries get cleared to null causing infinite recursion when the code attempts to place a value back into the map. It¹s probably a sequence of steps like this: 1. Low memory 2. Map entries cleared 3. Code executes to fill 1 or more 4. Low memory 5. Map entries cleared 6. Repeat
To prevent this kind of problem as well as improve locality of reference, I would use a strong HashMap instead of a WeakHashMap; however, I do not know anything about the internals of AJ. In general, locality of reference is ridiculously important for these kinds of caches because O(c) where c is the number of CPU cache pages is paramount. In fact, I would even consider binary searching an array depending on the testing characteristics of this particular map; i.e., how often it is accessed, what the typical pattern is, how difficult the comparison operation is, and how likely the array dereferences are to be already in (CPU) cache. In many cases, reducing O(c) is more important than reducing O(n) where n is the number of algorithmic operations. From: Santiago Aguiar <[EMAIL PROTECTED]> Reply-To: <[email protected]> Date: Fri, 30 Mar 2007 11:31:11 -0300 To: <[email protected]> Subject: Re: [aspectj-users]java.lang.StackOverflowError atorg.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:292) Hi Kevin! No, its a completely standard Sun 1.5.0_09 VM ;), and I do agree with you about stack handling. I had some trouble getting to the AspectJ source code (I don't understand why don't we get a source distribution when the binaries are released...), but I'm betting this problem is related to how AspectJ works with generic types. And thinking about the memory issue, probably some entry in the weak hash map gets cleared when I have less memory as is garbage collected, but as I increase it, the entry is kept in memory and therefore the map still holds a valid reference..... thanks! saludos, Kevin F wrote: > Re: [aspectj-users]java.lang.StackOverflowError > atorg.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:292) > Unless you¹re talking about a really strange VM with which I am unfamiliar, > the VM allocates the entire stack allocation size each time a thread is > started. No additional allocations take place for the stack itself; i.e., it > will not grow. > > I guess I am left wondering why type maps are being stored in a WeakHashMap > instead of a strong one. > > Just my 2 cents, > Kevin > > > > > From: Ron Bodkin <[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]> > Organization: New Aspects of Software > Reply-To: <[email protected]> <mailto:[email protected]> > Date: Thu, 29 Mar 2007 12:39:26 -0700 > To: <[email protected]> <mailto:[email protected]> > Subject: RE: [aspectj-users]java.lang.StackOverflowError > atorg.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:292) > > Interesting. I wouldn¹t have expected that, but perhaps the VM ran out of > heap memory in allocating a stack frame and because it ran out of memory it > reported stack overflow. > > > > > > > > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> On Behalf Of Santiago Aguiar > Sent: Thursday, March 29, 2007 12:33 PM > To: [email protected] > Subject: Re: [aspectj-users]java.lang.StackOverflowError > atorg.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:292) > > Hi Ron! > > Thanks a lot for the reply! > > The strack trace is of 1024 function calls... it seems a bit too deep for me > (I didn't paste the full stack trace in the email). > > I tried your suggestion and it didn't work. However it made me thing and I > added -Xms128m -Xmx256m (since I'm passing those parameters when running in a > lab where I don't get the error) and it solved the problem..... > > I don't exactly see why having less available memory would result in a > StackOverflow instead of an OutOfMemory error..... > > Ron Bodkin wrote: > Hi Santiago, > > You might try running your test with a larger stack size, since this doesn¹t > look like an infinite loop. Try adding a VM argument Xss2048k to your junit > runner to do this. This value is four times the default, so you probably can > run with less, but doing this should test whether this fixes the problem (as I > suspect it will). Java programs with deep stacks sometimes need a larger value > here. And running from Eclipse has different stack depths, so the discrepancy > isn¹t too surprising. > > > > > > > > > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]> On Behalf Of Santiago Aguiar > Sent: Thursday, March 29, 2007 8:39 AM > To: [email protected] > Subject: [aspectj-users] java.lang.StackOverflowError > atorg.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:292) > > Hi, > > I'm using AspectJ 1.5.3 using LTW and writing *most* of my aspects code style. > I get the following stack trace when running a test case from ant: > > [junit] java.lang.StackOverflowError > [junit] at > java.util.WeakHashMap.expungeStaleEntries(WeakHashMap.java:269) > [junit] at java.util.WeakHashMap.getTable(WeakHashMap.java:297) > [junit] at java.util.WeakHashMap.get(WeakHashMap.java:341) > [junit] at org.aspectj.weaver.World$TypeMap.get(World.java:967) > [junit] at org.aspectj.weaver.World.resolve(World.java:250) > [junit] at org.aspectj.weaver.World.resolve(World.java:191) > [junit] at > org.aspectj.weaver.UnresolvedType.resolve(UnresolvedType.java:662) > [junit] at > org.aspectj.weaver.ReferenceType.getRawType(ReferenceType.java:550) > [junit] at > org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:292) > [junit] at > org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:276) > [junit] at > org.aspectj.weaver.ReferenceType.isAssignableFrom(ReferenceType.java:292) > ..... > > Strangely, I don't get the error if running my test cases from inside Eclipse. > If I'm not wrong, eclipse uses it's own compiler while when running from ant > I'm compiling with Sun's compiler (1.5.0_09). > > I don't really know what else to do... I suspect the issue is while handling > generics, but not much else. I'm willing to provide any additional information > to help me diagnose the problem. > > I'm attaching the generated ajcore files. > > thanks a lot, > > saludos > > -- > santiago aguiar > netlabs > Palmar 2548 > Montevideo, Uruguay > Tel. +(598 2) 707 7687 > Fax. +(598 2) 709 4866 > http://www.netlabs.com.uy > > > > > > > > > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > > -- > santiago aguiar > netlabs > Palmar 2548 > Montevideo, Uruguay > Tel. +(598 2) 707 7687 > Fax. +(598 2) 709 4866 > http://www.netlabs.com.uy > > > > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > > > > > > _______________________________________________ > aspectj-users mailing list > [email protected] > https://dev.eclipse.org/mailman/listinfo/aspectj-users > -- santiago aguiar netlabs Palmar 2548 Montevideo, Uruguay Tel. +(598 2) 707 7687 Fax. +(598 2) 709 4866 http://www.netlabs.com.uy _______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________ aspectj-users mailing list [email protected] https://dev.eclipse.org/mailman/listinfo/aspectj-users
