You are not logged in.

birosys

Trainee

  • "birosys" is male
  • "birosys" started this thread

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

1

Wednesday, September 16th 2009, 10:15pm

Java and memory usage

Hi to all

When I start java program, memory usage of javaVM is about 20MB. Only form, nothing else.
If i use any other jar lib (like JasperReport) normaly javaVM take more memory(45MB!!!).
But, after closing and unloading all custom used objects, VM don't deallocate any byte of memory.

Is it normal?

Thanks
Milan

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Wednesday, September 16th 2009, 10:26pm

Hi,
memory de-allocation is done by the Java garbage collector ("gc").
The gc strategy is fairly complex. Depending on your system, it may take quite a while, until the memory gets freed.
Google is your friend if you would like to get to know more details ...

Greetings

A1880

birosys

Trainee

  • "birosys" is male
  • "birosys" started this thread

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

3

Wednesday, September 16th 2009, 11:17pm

Thank you A1880
Milan

  • "StefanSchnell" is male

Posts: 102

Date of registration: Mar 13th 2009

Location: Oberirsen - Germany

Occupation: Senior Software Engineer

Hobbies: Programming aund Photography

  • Send private message

4

Thursday, September 17th 2009, 12:57pm

Hello Milan,

if you want to see a lot of internals about your JavaVM try this:
1. Go to the path [Drive]\Programs\Java\jdk1.6.0_16\bin
2. Start the program jvisualvm.exe
3. And now you see all you want: CPU usage, GC activity in the Monitor tab or all running threads in timeline, table and and and
You find a lot of information about Java VisualVM here.

Sometimes a programmer must be a detective.

Cheers
Stefan
Visit my personal or commercial site
If you have questions or suggestions, write me an eMail or
meet me here

birosys

Trainee

  • "birosys" is male
  • "birosys" started this thread

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

5

Thursday, September 17th 2009, 10:22pm

Strange situation
Open and close report, and again do that, memory usage is over 100mb.
I try with Runtime.gc, but nothing happens.
It seems that VM don't release any mb of memory.

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

6

Friday, September 18th 2009, 11:11am

Hi Milan,
the explicit call of "gc" does not necessarily trigger immediate action.
The Java implementation is free how and when to start garbage collection.

The garbage collection cannot free any object which is still referenced.
So, programmers have to make sure that unused references are returned as soon as possible.
It is good coding style (in memory intense applications) to set such references to "null" to allow early gc.

You can start the Java virtual machine with special commandline parameters to get verbose gc logging.
The specific parameters depend on your Java implementation.
Try "java -Xloggc:myGcLog.txt ..."

Success!

A1880

birosys

Trainee

  • "birosys" is male
  • "birosys" started this thread

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

7

Wednesday, September 23rd 2009, 11:44pm

I try everything, no success ?(
The memory is not deallocated.
But, when i minimized app, memory is freed and size of vm is about 2MB.
What's happend?

Milan

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

8

Thursday, September 24th 2009, 12:59pm

I have a silly sounding question:
Why would you like the memory to be de-allocated? Why do you care?
Do you run out of memory? Do you have a memory shortage for other applications?

If you want save memory for other applications, you can specify the maximum amout of Java memory on the Java command line.
The Java garbage collector will strive to stay in the memory limits either specified by default or by your explicit parameters.

If you minimize an application, the graphics drawing buffers can be thrown away.
This alone is good for several MBytes pixel buffer.

Greetings

A1880

birosys

Trainee

  • "birosys" is male
  • "birosys" started this thread

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

9

Friday, September 25th 2009, 1:11am

Very simple answer: start 5 different reports, and memory usage is 250mb. In Serbia, PIV on 2ghz, and 1gb of RAM is well bred configuration.
I think that it is not normal.
By the way, i was reading about custom classloaders, loading classes with them, and after finishing job, set null reference to classloader. What you think about that A1880?
And again, thank's for your answers :thumbup:

Milan

birosys

Trainee

  • "birosys" is male
  • "birosys" started this thread

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

10

Friday, September 25th 2009, 1:27am

A1880, i must apologize to you. I don't read carefully your last post.
The -Xmx parameter on Java is solution for my problem.
Thank's again.
You are the best :thumbsup:

Milan

Youtube

Beginner

  • "Youtube" is male

Posts: 14

Date of registration: Sep 15th 2009

  • Send private message

11

Friday, October 2nd 2009, 5:51am

Use RAMBOOSTER

it frees up mem

and clears some too

its quite good

or use TaskManager press Ctrl + Alt + Delete to open

select it then end process

or process explorer

select

This post has been edited 1 times, last edit by "Youtube" (Oct 2nd 2009, 6:06am)


Rate this thread
WoltLab Burning Board