Bug 27002

Summary: Scanner allocates new ArrayList(10) everytime it's created
Product: [Eclipse Project] JDT Reporter: Adam Kiezun <akiezun>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.1 M4   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Adam Kiezun CLA 2002-11-22 13:41:04 EST
Scanner creates a new instance of ArrayList of size 10 everytime a new Scanner 
is created, regardless of checkNonExternalizedStringLiterals is true or false
after 10 seconds of typing in the editor, that sums up to almost 3MB of 
'Object[]'
Comment 1 Olivier Thomann CLA 2002-11-22 15:05:34 EST
This is easy to fix.
Simply need to replace:
lines.add(currentLine);

with:
if (lines == null) {
   lines = new ArrayList();
}
lines.add(currentLine);
Comment 2 Olivier Thomann CLA 2002-11-22 15:42:28 EST
All JDT Core tests are green with such a change. I can release it upon request.
Comment 3 Olivier Thomann CLA 2002-11-22 15:49:52 EST
You might want to reuse the scanner has much as possible anyway. setSource(...)
and resetTo(...) methods are for this purpose. A scanner is not a small object
and it should be used carefully.
Comment 4 Philipe Mulet CLA 2002-11-22 17:11:33 EST
Why not simply deleting the slot, it does no longer seem used anymore...
Comment 5 Philipe Mulet CLA 2002-11-22 17:14:24 EST
Removed slot, fixed.
Comment 6 Adam Kiezun CLA 2002-11-25 06:44:37 EST
thanks, that was a big one - like 600K every time you open a new editor
Comment 7 David Audel CLA 2002-12-18 10:45:13 EST
Verified.