0

I have this multithreaded application that executes tasks when they are sent to it. These tasks are sometimes memory heavy but sometimes not as much.

Either way, I am looking at Java Visual machine on the unix server that the application is running and also on a process level at unix using "top".

I can see on the JVM graph that as soon as the task is completed the heap is freed up, but the allocated memory for the process only grows (that's the RES field in the top command).

What could be the reason for this and what are potential options to fix this?

Many thanks, Gosho

trincot
  • 317,000
  • 35
  • 244
  • 286
  • this is not a programming question. But you may find this useful: http://unix.stackexchange.com/questions/53447/does-free-unmap-the-memory-of-a-process – Jean-Baptiste Yunès Mar 07 '16 at 20:11

2 Answers2

1

One simple reason being may be Java has not executed any Garbage Collection cycle or not the GC cycles which really releases memory back to OS.

This article explains how GC cycles release memory back to OS.

Adam B
  • 3,775
  • 3
  • 32
  • 42
Amit Naik
  • 983
  • 1
  • 5
  • 16
0

The reason is the way how the operating system (and the JVM) handles memory allocation for a process. As long as you have enough free physical memory, there is no reason to reclaim memory, which is allocated to a process (the process will likely need this memory again, so reallocating the memory would be a rather expensive task). There is nothing wrong here, so you have nothing to fix.

dunni
  • 43,386
  • 10
  • 104
  • 99