Author Topic: How to enable MusicBee to run up to 4GB of memory (System.OutOfMemoryException)  (Read 31257 times)

theta_wave

  • Sr. Member
  • ****
  • Posts: 680
For those with large libraries containing a sizeable amount of metadata, MusicBee tends to use a lot of memory.  The problem is that once it reaches a threshold (.NET threshold for 32bit programs is 1.3 GB), System.OutOfMemoryException error messages will pop up and sometimes cause MusicBee to crash.  There is a way to bump up this threshold up to 4 GB by one of two ways: 1a) Run editbin.exe included in a package by Steven or 1b) run editbin.exe included in Microsoft Visual Studio (Community Edition).

Which way is easier?  "1a" should do the trick in one step, but if you are OCD and absolutely need to know whether editbin.exe worked, then "1b" is the way to go.  Besides, if editbin.exe doesn't work, then you won't see MusicBee run significantly above 1.3GB in task manager before crashing.

1a) Editbin.exe from Steven's package

i) Download link: https://www.mediafire.com/file/9h6dxa3wcg84tdh/EditBin.zip/file

ii) Extract all three files from it and copy it to MusicBee's program directory (usually, C:\Program Files (x86)\MusicBee\)

iii) Run the following command (Go to MusicBee's program directory in explorer and type "cmd.exe" (without quotes) in the address window and hit enter):

Code
editbin /LARGEADDRESSAWARE MusicBee.exe

1b) Editbin.exe from Visual Studio

i) Download Microsoft's Visual Studio IDE (Community Edition) installer: https://www.visualstudio.com/

ii) Run the installer

iii) Click the "Individual components" tab and select "C++/CLI support" and "VC++ 2017 v141 toolset (x86,x64)" and finish the install

iv) Open up notepad and create a batch file with the content below.  Save it as "Filename_of_your_choice.bat" anywhere in your computer.

Code
@echo off
ECHO -------------------------------------------------------
echo Musicbee (LargeAddressAware)
Echo.
Echo Choose what do you want to do...
Echo 1. Enable /largeaddress aware flag
Echo 2. Check the status of MusicBee.exe
Echo.
ECHO -------------------------------------------------------

CHOICE /C 12 /M "Select one:"

:: Note - list ERRORLEVELS in decreasing order
IF ERRORLEVEL 2 GOTO CHECK
IF ERRORLEVEL 1 GOTO ENABLE

:CHECK
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\dumpbin.exe" /HEADERS "C:\Program Files (x86)\MusicBee\MusicBee.exe" | more

:ENABLE
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\editbin.exe" /LARGEADDRESSAWARE "C:\Program Files (x86)\MusicBee\MusicBee.exe"
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\dumpbin.exe" /HEADERS "C:\Program Files (x86)\MusicBee\MusicBee.exe" | more

v) Double click the bat file you just created.

Checking whether it worked, those who followed 1a earlier proceed to 1a below; likewise those who followed 1b above proceed to 1b below.

1a) Dumpbin.exe from Visual Studio

i) Install Microsoft Visual Studio according to 1b)-i) through iii)

ii) Hit Windows Button+R, type cmd.exe and press enter

iii) Copy and paste the following in the command line:

Code
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\dumpbin.exe" /HEADERS "C:\Program Files (x86)\MusicBee\MusicBee.exe" | more

iv) Hit enter

v) The result should match the highlighted message from the picture below: "Application can handle large (>2GB) addresses."

1b) From the .bat file made earlier

The bat file you made should produce a screen similar to the one below.  Pay attention to the highlighted portion: "Application can handle large (>2GB) addresses."

Last Edit: July 07, 2023, 09:23:11 PM by phred

stewlewis

  • Newbie
  • *
  • Posts: 19
http://www.ntcore.com/4gb_patch.php

I've used this before on Serato, don't know ifnit helped, or if it does the same as you described easily.

theta_wave

  • Sr. Member
  • ****
  • Posts: 680
http://www.ntcore.com/4gb_patch.php

I've used this before on Serato, don't know ifnit helped, or if it does the same as you described easily.
Most likely.  One can use the dumpbin.exe method in my post to check if the executable is patched properly or see if Musicbee goes above 1.3GB of RAM usage without crashing.  It is just that the way I described is pretty transparent on what's happening whereas your linked patcher is a black box.  Who knows what else it does.  People are free to choose of course.

theta_wave

  • Sr. Member
  • ****
  • Posts: 680
I edited the bat file in for 1b, where a menu prompt is presented to the user upon running it (CTRL+C at any time to exit from it):


Mr. Trev

  • Sr. Member
  • ****
  • Posts: 454
Couple of questions:

I assume this will work for the portable version?
Does this need to be done everytime a patch is applied?

Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312
It will work with all versions and would need to be re-applied each patch.
However it should be extremely rare that anyone would need to do this ie. you would need to have a large library with a lot of metadata for each file

mindlessbuddha

  • Newbie
  • *
  • Posts: 3
Is this still a relevant way to solve this problem.  I have a large external drive of music files with lots of metadata, experiencing crashes when used for a long time or if the computer sleeps. 1a link doesn't work to download without signing up for something and the link also brings up a bunch of junk popup windows. seems super suspicious and asked for permissions.  1b instructions are a bit dated now. I don't have the exact same selections as listed in the instructions.  If this is still good, can we get updated information/links.  Thanks! I'd really like to fix this crash issue and this seems like the only thread that addresses my exact problem.

theta_wave

  • Sr. Member
  • ****
  • Posts: 680
1b instructions are a bit dated now. I don't have the exact same selections as listed in the instructions.  If this is still good, can we get updated information/links.  Thanks! I'd really like to fix this crash issue and this seems like the only thread that addresses my exact problem.
Can you list (or post a screenshot) of the options listed to you by the installer for the community edition of Visualstudio (community edition)?


Steven

  • Administrator
  • Sr. Member
  • *****
  • Posts: 34312

sveakul

  • Sr. Member
  • ****
  • Posts: 2438
As an add-on to the "Checking whether it worked" section in theta_wave's original post, if you don't want to have to download the VS Community Tools package just to get at dumpbin.exe, the small app "wumpbin" will do the same thing, despite it's being a bit dated.  Check it out here:  http://www.benf.org/other/wumpbin/index.html .


sveakul

  • Sr. Member
  • ****
  • Posts: 2438
Besides using wumpbin.exe or dumpbin.exe, another way to verify that the LARGEADDRESSAWARE flag has been set by editbin.exe is to use the small GUI app "Large Address Aware 2.0.4 (NetFramework 4.5 version)" available at the bottom of the post here: https://www.techpowerup.com/forums/threads/large-address-aware.112556/ .

Select the app's "Intermediate" Mode first, then use "Add Files" which results in an immediate "read" of the flag.  The picture below shows the result for a copy of MusicBee.exe that just had the flag set using Steven's EditBin.zip package:



I confirmed that the file is not altered in any way by LAA 2.0.4 itself during the read-only process by doing before and after SHA-256 hash shots of the file just after using editbin.exe to set the flag and then after the LAA 2.0.4 "read" of the file.

The app can actually be used to set the flag itself (no editbin.exe), but since the hash obtained using that method did not match the hash using editbin, I would strongly advise NOT using LAA 2.0.4 to set the flag, only to confirm it has been set by editbin.

jpirez

  • Jr. Member
  • **
  • Posts: 24
Hi

I have followed Steve's instructions but I am getting this error:

LINK : fatal error LNK1104: cannot open file 'MusicBee.exe'

Any advice?

Thanks in advance
Jose

sveakul

  • Sr. Member
  • ****
  • Posts: 2438
Are you using the "Windows Store" version of MusicBee?  If so, the whole process will not work.

If you have the Portable or Installer versions:

1. Be sure you are running editbin.exe from the same folder as MusicBee.exe

2.  Be sure you downloaded the "revised" version of the package from Steven's newer post here: https://getmusicbee.com/forum/index.php?topic=22778.msg173343#msg173343 , and that you put the other two files in the zip, link.exe and tbbmalloc.dll, in the folder with editbin.exe and MusicBee.exe.

jpirez

  • Jr. Member
  • **
  • Posts: 24
Hi

I had to move the musicbee.exe from C: to another drive and then I was able to apply the patch successfully. Otherwise Windows 11 would not allow it.