简体   繁体   中英

Testing Java for a limited resource environment

I'm writing java that will run in an environment with little memory. My machine has loads of memory, so I need to limit the heap size (is this the only limit I can apply?). I've been using "-Xmx100m" as a VM parameter in eclipse, but when I run the application I can see in the task manager that the memory used goes well above 100MB. Am I using this incorrectly?

Also, most my memory is being allocated in local variables. These will be put on the thread's stack, which resides in the heap space, correct? Just curious, what if my program was made entirely of static methods, where would these local variables be allocated?

Thanks!

edit: I suppose I should make my question simpler: How can I visualize an environment with less resources just for the jvm?

The stack always exists and variables can be allocated on it - regardless if it is a static method or not.

I have also observed several times that jre actually uses more memory than specified with -Xmx setting. This is discussed in details in this question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM