Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326411

Summary: Moving a line using keyboard in css results in OutOfMemoryError.
Product: [WebTools] WTP Source Editing Reporter: Iwao AVE! <harawata>
Component: wst.cssAssignee: Rakesh <rakes123>
Status: RESOLVED FIXED QA Contact: Nick Sandonato <nsand.dev>
Severity: normal    
Priority: P3 CC: rakes123
Version: unspecifiedKeywords: performance
Target Milestone: 3.3 M5Flags: nsand.dev: review+
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
CSS file to reproduce the problem
none
Stack trace copied from the error log.
none
Simpler example file to reproduce the problem.
none
patch nsand.dev: iplog+

Description Iwao AVE! CLA 2010-09-28 09:27:38 EDT
Build Identifier: 20100917-0705

In a relatively large css file, OufOfMemoryError occurs when moving a line using keyboard shortcut (option + arrow key).
Increasing the max heap size (-Xmx1024m) seems not to help.

I will attach an example css and the stack trace.

Reproducible: Always

Steps to Reproduce:
1. Create a Static Web Project.
2. Copy the attached test.css in the WebContent folder.
3. Put the cursor at a line 5 (font-size:12px;) and hold down 'option key + down arrow key' to move the line continuously.

Before the line is moved to the bottom of the file (usually at line 117 on my environment), an 'Unhandled event loop exception' occurs.
Comment 1 Iwao AVE! CLA 2010-09-28 09:29:53 EDT
Created attachment 179738 [details]
CSS file to reproduce the problem
Comment 2 Iwao AVE! CLA 2010-09-28 09:31:24 EDT
Created attachment 179739 [details]
Stack trace copied from the error log.
Comment 3 Iwao AVE! CLA 2010-09-28 13:03:16 EDT
Created attachment 179765 [details]
Simpler example file to reproduce the problem.

Attached a smaller css file which causes the same OutOfMemoryError.
So, it seems that the size of the file does not matter.
Comment 4 Iwao AVE! CLA 2010-09-28 13:09:37 EDT
Forgot to mention how to reproduce the problem with the simpler css.
Move the second line (color:#F35B00;) down to line 5 using the keyboard shortcut (option + down).

I also found that if I insert a tab character at the top of the second line, the OufOfMemoryError does not occur.
Comment 5 Rakesh CLA 2010-09-30 01:14:16 EDT
Created attachment 179920 [details]
patch
Comment 6 Nick Sandonato CLA 2010-11-17 14:48:55 EST
Rakesh, I'm not sure if this patch will correct the reported issue. When holding down the Alt+Arrow Key, I never saw that ArrayList get larger than 4 elements, and all were unique. So I don't think using a HashSet is the solution.

I'm running at -Xmx512m, and even using the large css example, I cannot get the OutOfMemoryError by moving the line clear down to the bottom of the file. Are there any other details you can share with us? Maybe the heap dump file that was generated?

Thanks for your help.
Comment 7 Rakesh CLA 2010-11-17 23:25:03 EST
(In reply to comment #6)
> Rakesh, I'm not sure if this patch will correct the reported issue. When
> holding down the Alt+Arrow Key, I never saw that ArrayList get larger than 4
> elements, and all were unique. So I don't think using a HashSet is the
> solution.
> 
> I'm running at -Xmx512m, and even using the large css example, I cannot get the
> OutOfMemoryError by moving the line clear down to the bottom of the file. Are
> there any other details you can share with us? Maybe the heap dump file that
> was generated?
> 
> Thanks for your help.

Hi Nick, I was able to reproduce it again.
Try to move second line(color:#F35B00) in this simpler css:
Make sure that there is no tab or whitespace at that start of text.

.newmassage a:visited {
color:#F35B00;
}
.key {
float:left;
width:12px;
height:15px;
}

As soon as it reaches 5-th line, while loop in code just after the declaration 'List structures ' will become infinite , so amount of memory allocated doesn't make any difference.
Comment 8 Rakesh CLA 2011-01-20 00:34:25 EST
ping!
Comment 9 Nick Sandonato CLA 2011-01-21 16:30:46 EST
Code released to HEAD.