Java VM memory usage
There are two basic types of memory in Java:
1) Heap memory, which is the standard memory pool, storing most everything, like objects.
2) Direct memory, which is a faster form of memory, managed by our own pool, used for network and disk buffers in Vuze.
The two pools are mostly independent from each other in terms of real memory usage, but the direct memory pool is limited in size by default (under java 1.4.2_05 and 1.5 series) to the max heap size. Note that on more recent OSX (i.e. Apple) JVMs it appears that the default size for the direct memory pool is limited to 64MB, *not* based on the heap size. You therefore need to explicitly use -XX:MaxDirectMemorySize= to increase beyond this.
The heap size defaults to 64mb, but if you use the Azureus.exe launcher to run, it sets the min heap to 16mb and the max to 128mb. Thus, the heap size can vary dynamically.
The default settings are such that you will not have any memory issues downloading and seeding a fairly large number of torrents. However, each torrent added to Vuze consumes some resources, especially when the torrent is actually running (as opposed to Stopped or Queued). If you have hundreds of torrents then it is possible to use enough memory to start causing issues.
If either of these pools are exhausted, things get nasty.
- Heap exhaustion leads to Vuze hanging, and sometimes crashing, as it becomes impossible to allocate memory required to continue running the application - this includes refreshing the user interface. Prior to exhaustion the VM becomes more and more frantic trying to free memory and while doing so will start using significant processor resources. Thus the typical behavior is that Vuze will start consuming CPU and become more and more unresponsive, ultimately hanging and requiring a hard quit to terminate it.
- Direct memory exhaustion doesn't tend to affect the Vuze user interface as it causes issues at the network/IO level. Rather torrents will go into error states with messages indicating that network or IO errors occurred. Increasing the disk cache (below) significantly can cause issues, as can increasing the number of connected peers to a very large value.
Changing Memory Options
On Windows there is a simple way to change the Heap size - go to tools->options. Make sure your 'mode' is at least 'Intermediate' under the 'Mode' options. Then go to the 'Startup & Shutdown' options and put your desired value (e.g. 192m) in the 'Max Heap memory size' entry and hit Save. You must restart Vuze for this to take effect.
On Mac OSX, starting in 188.8.131.52_B16, the process is the same as Windows. Otherwise, in Vuze 5.7.x with Java 7 or higher, you can create a ~/Library/Application Support/Vuze/java.vmoptions file with the desired options.
On Linux you will need to modify the vuze shell script. This shell script is actually a link to a file called azureus, vuze's previous name. Within this script change the line JAVA_ARGS="-Xmx128m" to JAVA_ARGS="-Xmx256m", for example if you want to increase the memory to 256MB. Then restart vuze.
To explicitly set the maximum size of the Heap, use the -Xmx command line option. For example, for a maximum heap size of 192 MB use -Xmx192m To set the maximum Direct memory use the -XX:MaxDirectMemorySize= option. For example, for a maximum Direct size of 192 MB use -XX:MaxDirectMemorySize=192m See Commandline_options for details on how to specify command-line options to Vuze
The disk cache uses direct memory of course, so you don't want to set it greater than the direct mem limit (which defaults to HEAP:max, but is overrideable via the -XX:MaxDirectMemorySize= command line option), or else you'll get those memory usage error alerts. With the disk cache, a little bit goes a long way, so 10 to 20 MB will probably do just fine (and you can check the cache hit rates in the stats view). Never use more than 32 MB cache.
Read the Azureus FAQ