jedit GC macro snafu :D
comments | Posted in jedit | snafu | texteditor on Friday, September 28 2007 09:42:00 PDT

Java/JEdit eats up my memory slowly

Java under Mac OS X is kinda chuggy and I think my memory footprint slowly walks away from me. So, my bright idea at 7am. Write a small script to live in /startup to call the GC every 3 minutes. No headache on my end and I dont care it does useless work every few minutes.

DO NOT RUN THE FOLLOWING MACRO IN JEDIT ... OR SET IT AS A STARTUP SCRIPT

:D

import java.lang.Thread; import java.lang.Runtime;

// Simple cron-like GCing every few minutes for jEdit.

try {

while (true) {
    second_unit = 1000; // unit of millisecond.
    rest_time = 300 * second_unit;
    Runtime r = Runtime.getRuntime();
    r.gc();
    Thread.sleep(rest_time);

}

} catch (Exception e) {

System.out.println(e.getMessage());

}

So its in /startup, and I debug the code in Jedit's Utilities -> Beanshell -> EvaluateSelection. The next thing I know my selection won't unselect, the menus dont respond, and the OS X dashboard can't even close the application .... teh froze :(

So I'm laughing at myself going ... I put it to sleep ... for 3 minutes ... I have a 0.003 window to close it in 3 minutes!! :P. Sigh, so I resort to OS Xs System Monitor and kill the application manually. JEdit restarts ... and immediately hangs :D hahahaha.

My Simpler solution

// David Gurba // 28 Sept. 2007 // gc-cleanup-safe.bsh // // usage: place in ${jedit_home}/macros/misc/ // tie a keyboard macro to it. I use: Ctrl+G+Ctrl+C. Runtime.getRuntime().gc();

Now its up to me to GC. But I dont have to use the mouse to activate it, my hands can stay comfortablely on the keyboard.

blog comments powered by Disqus