Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Force JVM to garbage collect externally?

Name: Anonymous 2010-10-30 19:13

I'm running PS3 Media Server on Arch Linux, and it's using quite a bit of memory that I'm sure could be collected if the JVM would just try. Is there any way for me to get the process to garbage collect? Maybe I there's a signal I can send to it?

Name: Anonymous 2010-10-30 19:15

that's not how garbage collection works

Name: Anonymous 2010-10-30 19:15

IHBT

Name: Anonymous 2010-10-30 19:17

What I've done with my own Clojure programs is start a REPL server, then connect to the program's REPL and call (System/gc). PS3 Media Server has no such REPL, but maybe you could try patching and compiling it yourself to give it a Clojure REPL?

Name: Anonymous 2010-10-30 19:34

Stop micromanaging memory usage.  If it's such a big problem, get a job and buy more RAM.

Name: Anonymous 2010-10-30 20:59

You can evoke Java's garbage collector manually inside your application, but there's no guarantee it'll do anything.

Name: Anonymous 2010-10-30 23:42

You should be able to force the JVM to GC, for example by recompiling or modifying the bytecode of your application.

In other cases one might not be as fortunate, for example I'm using a certain application written in SEPPLES right now and it's eating about 1.1GB of RAM at the moment due to memory leaks. A simple restart should get it in shape to some 40MB usage, at least for another day, when I'll have to restart it again.

Name: Anonymous 2010-10-30 23:44

>>7

Valgrind?

Name: Anonymous 2010-10-31 0:59

>>8
It's a closed source application, and I'm not annoyed enough to actually reverse engineer the application to fix bugs that the original authors should fix.

Name: Anonymous 2010-10-31 1:46

[code]System.gc();[?code]

Name: Anonymous 2010-10-31 18:26

>>7
My first thought was Firefox.

Name: Anonymous 2010-10-31 19:24

Call System.gc() until the memory usage goes down.

Name: Anonymous 2010-10-31 19:51

>>9
>>10
>>12

how do you know it's a bug and that's not its normal memory consumption?

Name: >>9 2010-10-31 20:10

>>13
The application is a client, it works with large streams of data, after which those streams are released, in the sense that you won't make use of them. The application is supposed to be in a "clean" slate after all of these streams have been released, yet I see some extra 1GB memory usage after a days usage - 1GB of memory which will never be used by the application again, and can't be used in any way by the user - restarting the application would return it back to the same exact state, except now it only uses 40MB. It's clearly a leak of sorts, but a restart is only a hotkey away, so it's not really a major concern for me right now.

Name: Anonymous 2010-10-31 20:15

>>14
Sounds like you just need to drop the caches.
echo 3 > /proc/sys/vm/drop_caches

Name: Anonymous 2010-10-31 20:50

Depending on how it is invoked, maybe the JVM can be told to prefer to garbage collect more often instead of expanding the heap? Isn't there a flag to set the maximum heap size?

Name: Anonymous 2010-11-01 0:04

>>16
-Xmx 128M

But if there's actually a leak in OP's application code, (s)he would be better off taking heap snapshots and using a profiling tool like JProbe or Yourkit to find out what's holding all that memory.

Name: Anonymous 2010-11-01 13:02

use jconsole or visualvm to trigger a garbage collection. some other random jmx command line client should do the job, too.

Name: Anonymous 2010-11-02 0:09

My favorite way to do Java collection is simple, elegant, and foolproof:

[code]srm -rf /usr/share/java

Name: Anonymous 2010-11-02 8:49

>>19
LOL XD

Name: Anonymous 2010-11-02 10:13

>>19
WHAT THE FUCK IS srm IS IT SOME UBUNTU SHORTHAND BULLSHYTE FOR SUDO?

Name: Anonymous 2010-11-02 11:53

>>21
sudo su -c sudo rm -rf /usr/share/java

Name: Anonymous 2010-11-02 15:03

>>2
You mean sudo su -c "sudo rm -rf /usr/share/java"

Name: Anonymous 2010-11-02 17:47

sls
scat
srm
ssudo
schmod

Name: Anonymous 2010-11-03 3:14

>>18
OP here. Thanks for actually helping. jconsole is just what I was looking for.

Name: Anonymous 2010-11-03 10:35

No no no, there is a signal you can send to it, can't remember the name, but if you send signal 8 the jvm will collect any garbage and free to reduce memory.

kill -8 `pgrep java`

Name: Anonymous 2010-11-03 12:05

>>26
kill -[b]9[/b] `pgrep java`

is the only way to force the JVM to let go of memory

Name: Anonymous 2010-11-03 12:15

>>26-27
Why the hell would you do it like that? Stupid.
pkill -9f java

Name: Anonymous 2010-11-03 20:51

spkill

Name: Adolf 2010-11-04 1:58

jewkill

Name: VIPPER 2010-11-06 7:35

JEWS

Name: Anonymous 2011-01-31 20:21

<-- check em dubz

Don't change these.
Name: Email:
Entire Thread Thread List