How can I assign more memory to bliss?

Sometimes you may receive error messages similar to:

java.lang.OutOfMemoryError: Java heap space

Or...

java.lang.OutOfMemoryError: GC overhead limit exceeded

Or maybe...

java.lang.OutOfMemoryError: Direct buffer memory

If you receive these messages it means bliss's internal memory has been exhausted. This is a bug in bliss, so please report it. While I look at the problem, a simple workaround may be to increase the amount of memory allocated to bliss.

Furthermore, bliss attempts to cache as much data in memory as possible to reduce the amount of disk I/O it performs. Loading music files demands quite a lot of memory, especially when embedded artwork is present, and so allocating as much memory as possible to these caches can improve performance.

bliss is, by default, limited to 512MB of internal memory usage. This means that bliss will use no more than 512MB internal to the bliss process. Total memory usage of the bliss process will be greater than that because of the overhead of the Java runtime environment and other requirements. This will vary from operating system to operating system.

Note that this allocation is a ceiling. bliss will use up to this amount and no more. It may not use the entire allocated amount of memory.

Allocating more memory to bliss is an advanced operation and requires editing text files. It is also dependent on your operating system. If you are uncomfortable doing this, wait for the diagnosis after you have reported the issue as I may be able to suggest an easier workaround (often it might be a specific music file causing the problem, for example).

Whichever operating system you use, first, stop bliss. Then proceed with the operating system specific instructions below...

Windows

To increase the memory allocated to bliss in Windows you must edit the bliss.l4j.ini file.

First, open up your favourite text editor. If you are using Windows Vista or later, you must do this as Administrator, otherwise you will not be able to save changes to the bliss.l4j.ini file.

Find %bliss%\bin\bliss.l4j.ini and open it inside your text editor. This will normally be C:\Program files (x86)\bliss\bin\bliss.l4j.ini. The contents should appear similar to:

-Xmx256M
-Djetty.home.bundle=com.elsten.bliss.jetty
-Dfelix.auto.deploy.dir="%EXEDIR%\\..\\bundle"
-Dbliss.bootstrapbundle.initialbundledir="%EXEDIR%\\..\\bliss-bundle"
-Dbliss.launcher="%EXEFILE%"
-Dorg.osgi.framework.storage="%HomeDrive%%HomePath%\\.bliss\\felix-cache"
-Djava.util.logging.config.file="%EXEDIR%\\..\\conf\\logging.properties"
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath="%TEMP%"
-XX:+CMSClassUnloadingEnabled

Edit "-Xmx256M" replacing 256 with the amount of MB you'd like to assign to bliss. I'd suggest you assign no more than ¼ of total system memory. The file may then look like:

-Xmx512M
-Djetty.home.bundle=com.elsten.bliss.jetty
-Dfelix.auto.deploy.dir="%EXEDIR%\\..\\bundle"
-Dbliss.bootstrapbundle.initialbundledir="%EXEDIR%\\..\\bliss-bundle"
-Dbliss.launcher="%EXEFILE%"
-Dorg.osgi.framework.storage="%HomeDrive%%HomePath%\\.bliss\\felix-cache"
-Djava.util.logging.config.file="%EXEDIR%\\..\\conf\\logging.properties"
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath="%TEMP%"
-XX:+CMSClassUnloadingEnabled

Save the file. bliss can now be run via the Start bliss (in background) shortcut, Start Menu or bliss.bat batch file. Using the batch file on the command line is helpful because an error will be shown if you made a mistake editing the file.

Mac OS X

The process is a little more involved in OS X. That's because of the way the bliss "app" is distributed. All of bliss's configuration is included in the application bundle, and that bundle is code-signed. This means making edits to the file is not allowed.

So the first step is to make a copy of the bliss.app file. This is simple; if you haven't already, first drag the bliss.app file out of the bliss.dmg to a location of your choosing. Many people choose /Applications. Next, make a copy of the file. You could name it something like bliss-more-memory.app. This copy can be located anywhere.

Now we can edit the memory. A .app "application bundle" is actually a folder with a standardised layout inside (meaning the files and folders within have standardised names). It's possible to see these folders by right-clicking the app and selecting Show package contents. You can also use the command line in Terminal. Once you can see the contents, you need to locate bliss-more-memory.app/Contents/app/bliss.cfg. Open bliss.cfg in your favourite text editor. You should be able to find a section that looks like:

...[more settings]
-Xmx256M
...[yet more settings]

That emboldened 256 is what you need to change. Replace 256 with the amount of MB you'd like to assign to bliss. I'd suggest you assign no more than ¼ of total system memory. The file may then look like:

...[more settings]
-Xmx512M
...[yet more settings]

Save the file, and restart bliss from the copied bliss-more-memory.app file (or whatever you called it). bliss should start and will be assigned more memory.

Linux

Increasing the memory allocated to bliss, in Linux, involves setting the $BLISS_MAX_HEAP environment variable. This can be performed on the command line before launching the bliss shell script:

export BLISS_MAX_HEAP=512M

... sets bliss's memory assignment to 512MB. This needs to be performed once in each bash session before the script is first launched, although once it is performed it doesn't need to be done again in that session.

To make the change permanent you can add the above line into your ~/.bashrc or equivalent startup file.

Synology

Editing the amount of memory assigned to bliss in a Synology NAS is similar to Linux as the undelying operating systems are fundamentally the same. However, there are preconfigured restrictions on a Synology NAS that makes it a little more tricky.

First, you need to enable SSH access to your Synology NAS. This is the only way to browse and edit the internal files which allow you to assign more memory to bliss. Once you have SSH access you will be able to browse the root filesystem. Note you will need to log in as "root" to be able to edit the files.

Once you've done that, decide how much memory to assign. A good rule of thumb is to never exceed 1/4 of the system RAM. For a DS923+ which has, factory fitted, 4GB, that means 1GB to assign. Note that your NAS may have been modified to add more RAM.

Now it's time to change the settings. The first step is to become root:

sudo su

Once that's done, the best approach to assign more memory is to edit the script:

/var/packages/bliss/scripts/start-stop-status.sh

This is the script that is executed when the bliss package is run. Find the line starting:

BLISS_HEAP_DUMP_PATH=$TEMP_FOLDER VMARGS=" [...]

To assign 1GB RAM, prefix that line with BLISS_MAX_HEAP=1G, so the line should start:

BLISS_MAX_HEAP=1G BLISS_HEAP_DUMP_PATH=$TEMP_FOLDER VMARGS=" [...]

If you want to assign less than 1GB, for example 768MB, use the M modifier. E.g: BLISS_MAX_HEAP=768M.

Save the file and restart the bliss package. Go to http://[ip/syno name]:3221/about and you should see a line starting -Xmx with your memory assignment:

-Xmx1G

If that's correct, you know bliss is using your new allocation.


Any other FAQs I forgot or clarifications required? Post your ideas below!