How to use CrashPlan but keep the Java process from constantly using ridiculous amounts of RAM
I use CrashPlan for my online backup, & it’s great: reasonably priced, secure, easy to use. But there’s one problem. For better or worse, CrashPlan is a Java app, & one of the problems with Java apps is that they are greedy pigs when it comes to RAM usage. I’ve often noticed that Java was using close to 400 MB of RAM, even when nothing is happening (to be precise, when CrashPlan is just hanging out & not actually backing anything up).
Now, you can schedule CrashPlan to actually back up at certain times during the day, so I did that. CrashPlan only backs up from 5 p.m. to 9 a.m., but even so, I was still seeing the java
process running constantly, and a steady growth of RAM usage over time.
Why? Well, it turns out that the CrashPlan service is running constantly, even if you’re only actually backing up between certain times (this is so other machines & people can back up to you—it’s one of the many locations to which you can backup using CrashPlan). But I don’t need it to run constantly. When I say I want it off, I want it off. And then I want it back on to run when I want it to back my stuff up.
Here’s how to fix that—and keep its Java from being a horrifically greedy pig (Java will always be a greedy pig; this keeps it somewhat under control, albeit with a sledgehammer, as you’ll see).
Table of Contents
Turn off CrashPlan every day at 9 a.m.
Create a file in ~/bin/cronjobs
titled crashplanOFF.sh
& put the following in it:
Save the file & make sure it’s executable:
That turns off CrashPlan, but it has to be run manually. Let’s automate the process so it runs every day at 9 a.m.
As root, create a file1 in /Library/LaunchDaemons
2 titled com.granneman.crashplanOFF.plist
3 & put the following in it (replace granneman
with your last name & <username>
with your home folder’s name):
Save the file & change ownership:
Now load the plist so it’s active:
OK, you’re now turning off CrashPlan every day at 9 a.m. Now let’s make sure it starts running every day at 5 p.m.
Turn on CrashPlan every day at 5 p.m.
This is very similar to what we just did.
Create a file in ~/bin/cronjobs
titled crashplanON.sh
& put the following in it:
Save the file & make sure it’s executable:
That turns on CrashPlan, but it has to be run manually. Let’s automate the process so it runs every day at 5 p.m.
As root, create a file in /Library/LaunchDaemons
titled com.granneman.crashplanON.plist
4 & put the following in it (replace granneman
with your last name & <username>
with your home folder’s name):
Save the file & change ownership:
Now load the plist so it’s active:
OK, you’re now turning on CrashPlan every day at 5 p.m.
We’re not done.
Make sure Java doesn’t go hog wild
For months now the same series of events has been occurring: I would look at iStat Menus & notice that Java was eating up a bunch of RAM, so I would manually kill the java
process.
Java would die & then immediately restart, and soon enough (I’m talking often within a half hour), the java
process would be back about 200 MB of RAM, & often well above that.
Limiting CrashPlan to running from 5 p.m. to 9 a.m. will help this problem quite a bit, but when it is running, Java is going to start grabbing RAM like a starving man at a banquet. To keep Java within limits, I did the following.
Create a file named kill_java_mem.sh
in ~/bin/cronjobs
& put the following in it:
What’s this do? The comments should make it clear, but it figures out how much RAM the java
process is using. If it’s using over 200 MB of RAM, the script kills java
. Java will immediately start up again, & I’ve never noticed a negative consequence of killing it, so I’m fine with it.
Save the file & make it executable:
As root, create a file in /Library/LaunchDaemons
titled com.granneman.killJavaMem.plist
5 & put the following in it (replace granneman
with your last name & <username>
with your home folder’s name):
This will run the script every 10 minutes & help to keep Java’s memory usage under control.
I really wish CrashPlan wasn’t a Java app & didn’t require this much care & feeding, but now that I have these scripts & jobs in place, things should go a lot more smoothly.
-
If you don’t know how to do that (with vim, for instance), you can also use a text editor like BBEdit & then save the file in that location. BBEdit will prompt you for your Admin password. ↩
-
Note that’s the system Library folder in
/
, not your personal one in~/
. ↩ -
Obviously, replace
granneman
with your last name. Unless your last name is Granneman. In which case, why don’t I know you?! ↩ -
Notice the
granneman
in the file name & act accordingly! ↩ -
granneman
—change it. ↩