File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Performance and the fly likes Reduce JRE memory usage. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "Reduce JRE memory usage. " Watch "Reduce JRE memory usage. " New topic
Author

Reduce JRE memory usage.

dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Hi..

I'm using JRE 1.6 with update 13. I'm running it under redhat based environment. I'm running following program.



My ps command shows following output.

1744 root 203m S /bin/jre6/bin/java Test


See its eating 203MB..

can anyone suggest me how I can reduce this ?

Thanks in advance.


a.k.a stalker.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's most likely the virtual space being allocated, not physical.
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

David Newton wrote:That's most likely the virtual space being allocated, not physical.


are you talking about page files ? If yes then I want to reduce that page file usage also..
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You'd probably have to do something Linux-y, then; the best you could do with Java proper is use -Xms/-Xmx/etc.

What makes you think you need to do this?
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

David Newton wrote:You'd probably have to do something Linux-y, then; the best you could do with Java proper is use -Xms/-Xmx/etc.

What makes you think you need to do this?


I've also tried to start java with -Xms64M -Xmx64M parameters. But unfortunately it was showing the same amount of memory.

I've very low memory device (256 MB RAM and 256MB Flash Drive). As you can see java is eating up around 50% of memory.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

If you're running a standard JVM on an embedded system you're asking for trouble--I can almost guarantee you that you don't want to do that. Depending on the platform there are a number of alternatives available.
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

David Newton wrote:If you're running a standard JVM on an embedded system you're asking for trouble--I can almost guarantee you that you don't want to do that. Depending on the platform there are a number of alternatives available.


Great.. If you can suggest me an alternative please ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No; I know next-to-nothing about your platform and requirements--why not just search the web?
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

David Newton wrote:No; I know next-to-nothing about your platform and requirements--why not just search the web?


I did that too.. I've tried many VM named sablevm, tinyvm, apache harmoney, jamvm and kaffe etc. If you can suggest any alternative please ?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I still don't know anything about your requirements, technical or otherwise, why you rejected any of the VMs you listed, whether or not you're only considering free VMs, what CPU you're using, why you're considering Java if it doesn't meet your requirements, basically anything that would enable me to make any reasonable suggestions, so the answer is still no. Someone else might be able to help, though.
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

David Newton wrote:I still don't know anything about your requirements, technical or otherwise, why you rejected any of the VMs you listed, whether or not you're only considering free VMs, what CPU you're using, why you're considering Java if it doesn't meet your requirements, basically anything that would enable me to make any reasonable suggestions, so the answer is still no. Someone else might be able to help, though.


I'm using custom compiled linux. So some of these vm didn't work on it. And some worked but they've not performed well so I've rejected them. BTW Thanks for the reply and suggestion.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15956
    
  19

This is not an embedded system - it's a server computer, but it's probably a very old one. Unless we switched machines and OS's somewhere in the thread and I missed it.

256MB of RAM is a real problem these days. To run any recent version of the RedHat distros with X you'll need over 100MB RAM for the OS and GUI desktop alone, even before you start Java. And Java's core VM requirements are not insignificant. The "-X" JVM parameters refer to its working storage, not the fixed overhead like the core classes.

You can reduce the OS memory overhead somewhat by not running X. On the other hand, if you intend to run a Tomcat server, you probably need a minimum of 256MB just for Tomcat. And don't even think of trying to do software development with a modern GUI IDE on it. My main development machine has 1.5GB RAM and still runs short.

Also, if this is one of the older Red Hat releases, I don't guarantee that the Sun JVM will run on it, much less any of the custom embedded JVM's. Which often get their small footprint by discarding functionality.


Customer surveys are for companies who didn't pay proper attention to begin with.
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Yeah you are right. But as I said I've custom compiled linux. I don't have a X server installed on it. I've only console based linux and I'm using some light weight applications like busybox etc.. So if you can suggest any open source custom embedded VM. Its okay I will accept some discards of functionality.

Thanks.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
if you intend to run a Tomcat server, you probably need a minimum of 256MB


?? My Tomcat 5.5.9 server runs in the minimum 64mb, or 128 if I am feeling generous, and that is with a lot of object creation.

Bill
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

William Brogden wrote:
if you intend to run a Tomcat server, you probably need a minimum of 256MB


?? My Tomcat 5.5.9 server runs in the minimum 64mb, or 128 if I am feeling generous, and that is with a lot of object creation.

Bill


Okay Mr. william can you tell me how to run it in 64MB RAM without eating much page memory ?
Vlado Zajac
Ranch Hand

Joined: Aug 03, 2004
Posts: 245
dhaval yoganandi wrote:
are you talking about page files ? If yes then I want to reduce that page file usage also..


This is not about page file (a.k.a. swap). Virtual memory includes everything in process address space which includes memory mapped files, unused space, shared memory, IO memory, etc.

My "virteater" program eats 1TB of memory. That memory is purely virtual, it is never actually used and it is not backed by any physical space in RAM or disk. (I don't really have that much space.)


dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Alright so do you have any alternative light weight JVM ?
Andy McBee
Greenhorn

Joined: Jul 23, 2009
Posts: 5
Maybe, you should try static compilation? E.g. gcj, or (which I prefer) Excelsior JET.
dhaval yoganandi
Ranch Hand

Joined: Jun 06, 2009
Posts: 35

Andy McBee wrote:Maybe, you should try static compilation? E.g. gcj, or (which I prefer) Excelsior JET.


yes.. I'm using ecj for compilation.
Dmitry Leskov
Greenhorn

Joined: Mar 11, 2006
Posts: 7
dhaval yoganandi wrote:
Andy McBee wrote:Maybe, you should try static compilation? E.g. gcj, or (which I prefer) Excelsior JET.


yes.. I'm using ecj for compilation.

It seems to me that you are mistaking ecj for gcj. The former is the Eclipse Java source to bytecode compiler, whereas gcj can also produce a native executable that runs directly on the CPU, and so can Excelsior JET.

Specifically Tomcat users may wish to wait for Excelsior JET 7.0, currently in beta


Protect Your Java Code - Through Obfuscators And Beyond (free article)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reduce JRE memory usage.
 
Similar Threads
JAVA and MYSQL Problem
Thread synchronization problem...
Memory footprint and Java Sound
Interface methods
WeakReference, hard reference scope and JIT optimisation