Summary: | ClassFile wastes memory | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Chris Laffra <laffrac> |
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | fraenkel |
Version: | 3.2 | Keywords: | performance |
Target Milestone: | 3.2 M5 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Chris Laffra
2006-01-24 10:15:56 EST
I remember jerome fixing a couple of these already. I wanted to avoid: StringBuffer buffer = new StringBuffer(ame.substring(0, name.length() - 6)); this.name = buffer.toString(); which is even more costly. Would it be possible for the VM you're using to change its behavior and do the copy of the char array if its length is greater than the String's size ? The StringBuffer example actually wastes even more space. The only guaranteed way to reduce space is to use getChars(). This will of course cause 2 copies but you will always have the smallest amount of space used. Note this code has moved to PackageFragment#getClassFile(String). Changed PackageFragment#getClassFile(String) to use getChars(...). Code verified for 3.2 M5 using build I20060214-0010. |