易创论坛 - 因你而精彩
  [Search] 搜索   [Recent Topics] 最新主题   [Hottest Topics] 热门主题   [Members]  会员列表   [Groups] 返回首页 
[Moderation Log] 管理日志   [Register] 会员注册 / 
[Login] 登入 
ZKM OutOfMemoryError  XML
论坛首页 » J2SE技术交流
发表人 内容
eworkday



注册时间: 17/02/2009 09:38:31
文章: 761
离线

Q15. What can I do if I get an OutOfMemoryError or "Insufficient Memory to open classes" error?

Zelix KlassMaster holds a lot of information in memory for each class that it opens. So, the more classes you open and the more complicated those classes are the more memory you need. If Zelix KlassMaster tells you that there was insufficient memory to open your classes or if it crashes with an OutOfMemoryError then you can do one of the following:
  1. Give Java more memory to work with by using the -Xmx??m option where ?? represents the number of megabytes. (For example, the option -Xmx256m gives Java 256MB of heap space.)
  2. When you are running Zelix KlassMaster via Ant then you need to give more memory to Ant itself. An easy way of doing this is by setting the "ANT_OPTS" environment variable.
    e.g. set ANT_OPTS=-Xmx256m
  3. Use the "Tools/Garbage Collect" menu option or the gc ZKM Script statement after opening your classes and before obfuscating.
  4. Install more physical memory.
It is not recommended that you make use of virtual memory (by giving Java more memory to work with than is physically installed.) Performance will be unreasonably degraded as memory is swapped to and from the disk.


The gc Statement

The ZKM Script gc statement asks the Virtual Machine to perform garbage collection then puts its thread to sleep for a certain number of milliseconds. Whether garbage collection actually takes place depends upon the particular Virtual Machine. The statement puts its thread to sleep because, in some environments, garbage collection can take place asynchronously so it can be useful to give it time to do its work.

 

In theory, this option should not be required. In practice, with some Virtual Machines and when memory is low, it can be handy place this statement prior to one that will perform a memory intensive operation. If you are not having any memory problems then ignore this option.

Examples

<pre> gc; //Ask for garbage collection then sleep for 500ms - the default. gc 1000; //Ask for garbage collection then sleep for 1000ms. </pre>

Syntax

"gc" [integerLiteral] ";"

 

where integerLiteral is the number of milliseconds to sleep. The default is 500ms.
 





http://www.zelix.com/klassmaster/FAQ.html#Q15
http://www.zelix.com/klassmaster/docs/gcStatement.html

这篇文章被编辑了 2 次. 最近一次更新是在 01/06/2010 16:49:18


易创天成
[MSN]
 
论坛首页 » J2SE技术交流
前往:   
Powered by JForum 2.1.8 © JForum Team. Improved by EWorkday