Well, I suppose I can offer some tip that may help. Let me suppose you use Hotspot VM.
Sun's Hotspot VM 's heap space consists of three divisions for young generation, old generation and perminant generation. Young generation refers to objects that are created and usually it died in a short time. The corresponding division leverages copying to collect garbage. When some object survives after several gc, It is moved to old generation division, where mark-and-sweep is leveraged. And the perminant gereration is where class objects reside, its default size is 4M(I am not certain). Well, in case of String s = "xxxx"; "xxxx" is put into division of perminant generation. Your String is huge enough to exceed the size limit and of course throws OutOfMemory error. You can increase only the size of division of perminant generation to solve the problem by specifying some -X option. I am sorry to say that I lose my notebook the day before yesterday, so I cannot give any further tip. Regards, Jerry 2005/11/28, Eric Plante <[EMAIL PROTECTED]>: > Hi, > > I have a struts application(1.1) using Eclipse and Exadel Studio with tomcat > 5.5.9 using Jave 5.0 > > I have to deal with a huge String in memory, about 5-6M and every time I run > my web application, I get java.OutOfMemoryError: java heap space...always at > the same place(I fill a StringBuilder with the main String + other strings > so I am effectively dealing with 2 huge strings at that point). > > When I run my application with a smaller string, it works fine so I checked > for potential memory leak or bust but it seems to run just the minimum > strings and stringbuilder object the application requires and all the > objects should be destroyed properly. > > I checked the web and all I could find was to try raising the heap space > exept that java -server -Xmx512m doesn't see any server and it doesn't seem > to be a good idea to raise the heap stack anyway but I saw a post saying > that Java 5.0 was using a proper heap size(1G although I don't have 1G RAM, > I suppose it uses what it can.) > > I always thought that if there wasn't enough space in memory, applications > would use the HD as memory slowing down the application but at least it > wouldn't explode. > > Any idea how my problem could be solved? Are there any memory obscure > restrictions to String and StringBuilder I should know that books doesn't > say? I just can't see how 2 5M String in memory could be that much of a > problem in 2005. > > Thanks > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]