Bug 27002 - Scanner allocates new ArrayList(10) everytime it's created
Summary: Scanner allocates new ArrayList(10) everytime it's created
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-11-22 13:41 EST by Adam Kiezun CLA
Modified: 2002-12-18 10:45 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.