Chinaunix首页 | 论坛 | 博客
  • 博客访问: 526368
  • 博文数量: 150
  • 博客积分: 5000
  • 博客等级: 大校
  • 技术积分: 1705
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-11 23:29
文章分类

全部博文(150)

文章存档

2011年(9)

2010年(25)

2009年(94)

2008年(22)

我的朋友

分类: Java

2009-01-08 10:47:20

PhoneME Porting:
java platform heap是common native heap的一部分。默认的大小是1M和4M,如果没有
启用多任务,默认的大小是1M.
1.BuildFlags.hpp
#define USE_SET_HEAP_LIMIT 1
----->enable JVM_SetHeapLimit
----->default : HeapMin = HeapCapacity
----->打开JVM_SetHeapLimit后,java platform heap是固定的,不可以动态调整
----->关闭JVM_SetHeapLimit后,可以通过使用runtime option:
         =HeapMinSize
         =HeapCapacitySize
      来动态调整Heap大小

2.configuratiom_xml/constants_32bpp.xml
Memory Limit:
1.JAVA_HEAP_CAPACITY_MVM 256*1024 (256KB?)
2.JAVA_HEAP_CAPACITY_SVM 1024
---->build->generate->#define JAVA_HEAP_CAPACITY_MVM (256*1024)

3.midpNativeAppManager.h
#if ENABLE_MULTIPLE_ISOLATES
    //modify by ligang.shen, to fix runtime HeapCapacity issue
    #define MIDP_HEAP_REQUIREMENT (MAX_ISOLATES * 1024 * 1024)
    //#define MIDP_HEAP_REQUIREMENT (4 * 1024 * 1024)
#else
    #define MIDP_HEAP_REQUIREMENT (1024 * 1024)
#endif
------>midp_system_initialize
JVM_SetConfig(JVM_CONFIG_HEAP_CAPACITY, MIDP_HEAP_REQUIREMENT);

4.jams/runMidlet.c
#if ENABLE_MULTIPLE_ISOLATES
#define MIDP_HEAP_REQUIREMENT (MAX_ISOLATES * 1024 * 1024)
#else
#define MIDP_HEAP_REQUIREMENT (1280 * 1024)
#endif
----->JVM_SetConfig

5.JVM.cpp
JVM_GetConfig
JVM_CONFIG_HEAP_CAPACITY return HeapCapacity;

JVM_SetConfig
JVM_CONFIG_HEAP_CAPACITY HeapCapacity = value;
JVM_CONFIG_HEAP_MINIMUM HeapMin = value;

6.作用不明确的地方
a.Globals.hpp
#define GENERIC_RUNTIME_FLAGS(develop, product)    
  product(int, HeapCapacity, 1 * 1024 * 1024,                               \
          "Maximum size of object heap in bytes")                           \
                                                                            \
  product(int, HeapMin, 1 * 1024 * 1024,                                    \
          "Minimin heap size in bytes. 0 means for the system to pick "     \
          "a good initial value. This flag is ignored "                     \
          "if SUPPORTS_ADJUSTABLE_MEMORY_CHUNK=0")      

b.initialize_standalone_rom_generator
#if USE_SOURCE_IMAGE_GENERATOR
 if (HeapCapacity < 8 * 1024 * 1024) {
    HeapCapacity = 8 * 1024 * 1024;
 }
##########################################
Porting_Guide中的说明:
The JVM_SetHeapLimit API is provided to implement a user-administered space
in the Java platform heap. When this feature is on, the Java platform heap size is not
adjustable. However, it is possible to set build flags to turn off the
JVM_SetHeapLimit API, in which case the heap size is dynamically adjustable.
When the JVM_SetHeapLimit API is disabled, you can control the minimum and
maximum sizes of the Java platform heap by using the following runtime options:
   =HeapMinSize
   =HeapCapacitySize

Provide these parameters as you did the +CacheJarFileHandles parameter. The
Java Wireless Client software passes your values to its VM. For example, to set the
initial size of the Java platform’s heap to four megabytes and the maximum size to
16 megabytes, set the options as follows:
   =HeapMin4M
   =HeapCapacity16M

To help determine the required capacity of the Java platform heap, track the heap’s
size with the following APIs:.
   public long java.lang.System.freeMemory()
   public long java.lang.System.totalMemory()

Have your code request a full GC before calling these methods so that you get
precise values. Because getting the memory size this way is an expensive and
performance-impacting activity, consider using the following strategy to estimate the
size requirements of the Java platform heap:
   1.Start the Java Wireless Client software with a =HeapCapacitySize option that
      enables the application to start without an error.
   2.Exit the Java Wireless Client software, and restart it with a smaller Size.
   3.Repeat the previous step until you receive an error indicating that you are out of
      memory.
############################################
void * JVM_SetHeapLimit(void *new_heap_limit);
Sets the address of the new limit. The valid range is
  heap_start <= new_heap_limit <= heap_end.
The function returns the new value of heap_limit. If new_heap_limit
is higher than or equal to the current value of heap_limit, this
operation always succeeds, no GC will happen, and the function
returns the same value as new_heap_limit.
 
If new_heap_limit is lower than the current value of heap_limit,
the VM may execute GC. Still, the request may not be fully
satisfied. This function returns the new value of heap_limit, which
may be higher than the requested new_heap_limit.

The functions works only for an non-expanding Java heap. E.g.,
HeapMin must be equal to HeapCapacity.

Note: the return value is always rounded up to the next 4-byte boundary.

 
阅读(743) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~