kukooBlog

look to the master, follow the master, walk with the master, see through the master, become the master.

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  213 随笔 :: 0 文章 :: 285 评论 :: 0 Trackbacks

这是在eclipsepowered上看到的。 Ed提到了eclipse-dev committers mailing list中,Jerome Lanneluc 指出的一个String#substring和String(String)的问题。按照Jerome的说法,使用String#substring()的时候,原有的长字符串所占据的空间仍然被占据,并没有释放,使用String(String)可以解决这个问题。Jerome的原文:

I just noticed that String#substring(…) shares the underlying char array. So if you have a big string, take a substring of it, throw away the big string, you will still hold on the big char array. A simple way to solve this is to make a copy of the substring using the String(String) constructor.

I saved 550KB in JDT Core by changing the following code:

String simpleName =
fullyQualifiedName.substring(fullQualifiedName.lastIndexOf(
'.'));

to

String simpleName = new
String(fullyQualifiedName.substring(fullQualifiedName.lastIndexOf(
'.'))); 

Eclipse3.1发布以后,使用者发现,3.1占据了大量的Heap(大约200-300M)。Eclipse的开发小组正在不断地解决这个问题,而String#substing的改进,将在Eclipse 3.1M6中发布(4月1日)。

这个提示,其实也可以运用在我们自己的项目之中

[Note: This blog was migrated from my old CSDN blog.]

为什么重发这个blog呢?因为昨天看到Eclipse.org网站上关于Eclipse Performance的一个文档。这份文档主要是提示,在开发基于Eclipse的应用时(不管是Eclipse程序本身,还是Plug-in),在性能问题上需要注意的一些地方。其中,第一条就是如何使用substring()的问题。Eclipse 3.1M7以及RC1,都已经进行了这方面的调整,所以现在的Eclipse,对Heap的占用已经大幅减少,从而在性能上也有所提高。




Eclipse.org
eclipsepowered.org

Email this store to a friend (send a short email with a subject to this story)
Subscribe to kukooBlog (subscribe kukooBlog's RSS feed)
Send me feedback on this story

Yourit
Mycat EclipseProgramming

posted on 2005-06-03 09:04 kukooBlog 阅读(799) 评论(0)  编辑  收藏 所属分类: EclipseProgramming

只有注册用户登录后才能发表评论。


网站导航: