簡體   English   中英

限制Java RAM使用率?

[英]Limit Java RAM usage?

我們將Java用於我們的項目www.aerospaceresearch.net/constellation,並直接從已卸載的Java bin文件夾中使用Java。

我們在操作系統甚至32位和64位版本之間使用該java的ram用法存在一些麻煩。 是否可以設置ram使用的上限,以便Java對ram進行動態重新排列,例如始終低於150mb?

這確實可以幫助我們解決一些小問題,並將我們的應用程序帶入具有有限內存功能的系統。

在此先感謝,Andreas

從您的問題很難看出來,但是您可能正在Sun的 Oracle java工具中尋找-Xmx選項,該選項為Java內存堆設置了最大大小。

有關該版本的java工具提供的各種非標准功能(包括與堆相關的一些功能)的詳細信息,請在命令提示符下鍵入java -X 對於我安裝的版本,這給了我:

java -X
    -Xmixed           mixed mode execution (default)
    -Xint             interpreted mode execution only
    -Xbootclasspath:<directories and zip/jar files separated by :>
                      set search path for bootstrap classes and resources
    -Xbootclasspath/a:<directories and zip/jar files separated by :>
                      append to end of bootstrap class path
    -Xbootclasspath/p:<directories and zip/jar files separated by :>
                      prepend in front of bootstrap class path
    -Xnoclassgc       disable class garbage collection
    -Xincgc           enable incremental garbage collection
    -Xloggc:<file>    log GC status to a file with time stamps
    -Xbatch           disable background compilation
    -Xms<size>        set initial Java heap size
    -Xmx<size>        set maximum Java heap size
    -Xss<size>        set java thread stack size
    -Xprof            output cpu profiling data
    -Xfuture          enable strictest checks, anticipating future default
    -Xrs              reduce use of OS signals by Java/VM (see documentation)
    -Xcheck:jni       perform additional checks for JNI functions
    -Xshare:off       do not attempt to use shared class data
    -Xshare:auto      use shared class data if possible (default)
    -Xshare:on        require using shared class data, otherwise fail.

The -X options are non-standard and subject to change without notice.

如果您使用的是Java的其他實現,則這些選項可能會有所不同。 並注意上述末尾的警告。

您可以嘗試使用類似...

java -Xmx128m BigApp

但是,如果您的應用程序實際超過了128 MB的堆限制,則可能會出現內存不足的錯誤。

[更新]在64位方面,有一個特殊的參數使64位引用占用更少的空間,但我現在找不到它。 這是新JRE(1.6?)之一的標准配置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM