I recently installed Debian 6.0.6. Here are the machine's states:

  • CPU - AMD XP 3000+
  • RAM - 1 Gig
  • HDD - IDE 80 Gig

I primarily use this machine for developing toy personal projects. When I run NetBeans, I sometimes get a low memory error. Running top shows that, sure enough, RAM is at almost 100% usage. However, swap space usage is at 0. Does this mean that the swap partition that I created during installation is not enabled. I assumed that after creating the swap partition the installation process would automatically enable it. What do I need to do to enable swapping?

  • @don_crissti I'm not on that machine ATM, so I'll get back to you on those questions when I have a chance to check. I do recall that top showed the amount of swap space available as expected. – Code-Guru Oct 20 '12 at 18:36
  • 2
    @Code-Guru The java JVM has a maximum heap space size, which could be what you are actually hitting. -Xms and -Xmx settings adjust this. – jordanm Oct 21 '12 at 1:48
  • 1
    @jordanm I would say - right on mark. Make it an answer (and explain the differences between java and os memory)... – Nils Oct 21 '12 at 20:11
  • @jordanm I wondered if I might be running into Java-related memory issues. I found this FAQ explaining how to set the heap size in NetBeans. I'll have to try it out later. And feel free to add an answer with more details. You'll certainly get at least an upvote from me, and most likely I'll accept as well. – Code-Guru Oct 21 '12 at 23:26
  • @don_crissti Both /etc/fstab and swapon -s confirm that the swap space is mounted and enabled. In fact, a more recent top showed a little bit of swap space in use. I suspect that jordanm has the right idea bout the JVM heap size, so I'm checking into that. – Code-Guru Oct 21 '12 at 23:29

"Does this mean the swap partition that I created during installation is not enabled?": If you look at the stats on swap in top, it gives not only the amount in current use, but also the total amount available on the system, and the amount remaining. If all three of these numbers are 0, then yes, your swap partition is probably not enabled.

"What do I need to do to enable swapping?": swapon <swapdevice or file> If that fails, you may need to use mkswap on it first. If you want it to be permanent, add it into /etc/fstab.

If you have swap, and it's not being used, then you're probably running out of java heap space rather than system memory. There are parameters you can pass to java to adjust the amount of memory it will allocate for various purposes. Consult the java documentation or search stackexchange for details on how to use them. Be aware though that while java may technically run while swapping in and out like mad, its performance may not be adequate. Consider a memory upgrade for the machine in question in that case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.