minecraft beta (possible) memory leak issues and also bat file to (possibly) help performance
1 reply [Last post]
grelmo114
WoM Member
Contributor
WoM Member: 128972
WoM Coins: -2

elmo here,

I am geting a lot of Black
screens of death so i have switched from the exe version of minecraft
beta to minecraft.jar version. This means i can setup a run.bat file to
start my mincraft beta game. And im getting a lot better results.

how to:
1. go to minecraft official website then click "download".

2. ignore everything on the screen apart from the section about Linux / Other

3. click the "Minecraft.jar" or click this link http://www.minecraft.net/download/minec ... 7144220831
and download to desktop or where ever you like.

4. now you have minecraft.beta in jar form. we need to create a batch file(*.bat)

NOTE: the .bat is recommended to be in the same location as the minecraft.jar. You can always make a short-cut to the bat file.

5. Now in notepad copy and paste the below data

@echo off

rem If you have a custom path to java, change auto below to
rem point to your java.exe file
rem eg:  set JAVA6="C:\MyPath\bin\java.exe"

set JAVA6="auto"

set X86="%ProgramFiles(x86)%"
if %JAVA6% == "auto" (
  echo Autodetecting java
  if %X86% NEQ "" (
    echo Testing x86 folder
 
  for /D %%j in ("%ProgramFiles(x86)%\jre6*"
"%ProgramFiles(x86)%\jre1.6.*" "%ProgramFiles(x86)%\jdk1.6.*"
"%ProgramFiles(x86)%\Java\jre6*" "%ProgramFiles(x86)%\Java\jre1.6.*"
"%ProgramFiles(x86)%\Java\jdk1.6.*") do (
      echo Checking %%j folder
      if exist "%%j\bin\java.exe" (
        echo Found java in %%j folder
        set JAVA6="%%j\bin\java.exe"
      )
    )
  ) else (
    echo Testing default folder
    if defined ProgramFiles (
 
  for /D %%j in ("%ProgramFiles%\jre6*" "%ProgramFiles%\jre1.6.*"
"%ProgramFiles%\jdk1.6.*" "%ProgramFiles%\Java\jre6*"
"%ProgramFiles%\Java\jre1.6.*" "%ProgramFiles%\Java\jdk1.6.*") do (
        echo Checking %%j folder
        if exist "%%j\bin\java.exe" (
          echo Found java in %%j folder
          set JAVA6="%%j\bin\java.exe"
        )
      )
    )
  )
)

:rerun
if %JAVA6% == "auto" (
  echo ERROR: 32-bit Java 6 not found!
  echo Please download and install from java.com
  pause
  exit
) else (
  echo Starting java from %JAVA6%
 
%JAVA6% -Xmx1024M -Xms512M -Dsun.java2d.noddraw=false
-Dsun.awt.noerasebackground=true -Dsun.java2d.d3d=true
-Dsun.java2d.opengl=false -Dsun.java2d.pmoffscreen=false -cp 
Minecraft.jar net.minecraft.LauncherFrame
)

now
save the file in same location as minecraft.jar and save as run.bat or
go.bat or start.bat(what ever you like but must end in .bat)

6. now you have more options to use in helping improve performance and help stop the dreaded Minecraft(black screen of death)

7. lets look at the bat file we created and we have the following code:


 
%JAVA6% -Xmx1024M -Xms512M -Dsun.java2d.noddraw=false
-Dsun.awt.noerasebackground=true -Dsun.java2d.d3d=true
-Dsun.java2d.opengl=false -Dsun.java2d.pmoffscreen=false -cp 
Minecraft.jar net.minecraft.LauncherFrame

we can change and experiment with it.
-Xmx1024M = maximum memory allocation allowed to java to run minecraft.jar

-Xms512M = minimum memory allocation allowed to java to run minecraft.jar

-Dsun.java2d.noddraw = DirectDraw in the Java application.

-Dsun.awt.noerasebackground = directdraw may help to prevent flicker on resizing of minecraft window.

-Dsun.java2d.d3d = directdraw3d option to use or not, windows directx library to render 3d, may improve
performance.

-Dsun.java2d.opengl = unlike directdraw this is a generic 3d drawing library. Minecraft uses this as default.

-Dsun.java2d.pmoffscreen= Setting this flag to false disables offscreen
pixmap support, which can solve some rendering problems.

Have a
play with the above or look online to find other java runtime commands
that may help minecraft performance / and avoid a crashing of minecraft.

On doing testing.

It looks like redundant memory is not being unallocated before memory is filling up.

I saw the ram allocation on minecraft go from 800 to over a 1.2gb then it crashed out with black screen.

My allocation for java is 1.24gb max.

More experimenting, but im suspect it's a minecraft issue.

I am using windows 7 x64bit ultimate and using a 32bit java i might try 64bit java.

For 64bit windows you can get 64bit java here: https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jre-6u23-oth-JPR@CDS-CDS_Developer

Also you need to alter your bat file for 64bit:


@echo off

rem If you have a custom path to java, change auto below to
rem point to your java.exe file
rem eg:  set JAVA6="C:\MyPath\bin\java.exe"

set JAVA6="auto"

set X64="%ProgramFiles"
if %JAVA6% == "auto" (
  echo Autodetecting java
  if %X64% NEQ "" (
    echo Testing x64 folder
 
  for /D %%j in ("%ProgramFiles%\jre6*" "%ProgramFiles%\jre1.6.*"
"%ProgramFiles%\jdk1.6.*" "%ProgramFiles%\Java\jre6*"
"%ProgramFiles%\Java\jre1.6.*" "%ProgramFiles%\Java\jdk1.6.*") do (
      echo Checking %%j folder
      if exist "%%j\bin\java.exe" (
        echo Found java in %%j folder
        set JAVA6="%%j\bin\java.exe"
      )
    )
  ) else (
    echo Testing default folder
    if defined ProgramFiles (
 
  for /D %%j in ("%ProgramFiles%\jre6*" "%ProgramFiles%\jre1.6.*"
"%ProgramFiles%\jdk1.6.*" "%ProgramFiles%\Java\jre6*"
"%ProgramFiles%\Java\jre1.6.*" "%ProgramFiles%\Java\jdk1.6.*") do (
        echo Checking %%j folder
        if exist "%%j\bin\java.exe" (
          echo Found java in %%j folder
          set JAVA6="%%j\bin\java.exe"
        )
      )
    )
  )
)

:rerun
if %JAVA6% == "auto" (
  echo ERROR: 64-bit Java 6 not found!
  echo Please download and install from java.com
  pause
  exit
) else (
  echo Starting java from %JAVA6%
 
%JAVA6% -Xmx1024M -Xms512M -Dsun.java2d.noddraw=false
-Dsun.awt.noerasebackground=true -Dsun.java2d.d3d=false
-Dsun.java2d.opengl=false -Dsun.java2d.pmoffscreen=false -cp 
Minecraft.jar net.minecraft.LauncherFrame
)

after testing(playing java with task bar open on processes)
Here is the memory stacks as i play)

on start it's a respectable 48mb

after logging in, memory instantly shot up to 300mb-320mb

clicked on multiplayer and connected to a server I'm watching the memory increment up to about 500mb to 520mbmax
before i even built or done anything.

I'm not moving and it's shooting up to 535mb and rising... hang on lets see if it stabilizes.

at the moment after a minute or just login in no moving it's 560mb and creeping up.

this to me(hate to say it) like sloppy coding or maybe the multiplay still isn't fully sorted causing memory leaking..

still im not playing just typing(minecraft in background) on this post and it's now 600mb and slowly creeping up still.

im going to move around a bit.

after
2 mins of walking round and trying different setting e.g. render
distance short etc. the memory allocatin to javais still creeping up.
It's now 803mb.

ok i have hit a peek and it's stopped leaking at 815mb(not moving and on option menu)

I then warped to another location and now it's jumped hugely up to 945mb

i cannot rule out the server client could be causing issues, but can't be 100%.

as i type on the forum with minecraft in background it's going down to 942mb.

i am collecting material and now memory allocation is up to 959mb with no unused memory being unallocated.

Eventually after playing for either 30mins to an hour memory can exceed over 1,2gb even seen it go up to 2gb then crash.

Can't
prove if it's minecraft or server side effecting minecraft memory
management), but if i try single player. then i can compare memory
allocation.

stucky01
WoM Member
Members
WoM Member: 175030
WoM Coins: 1
Nice one!

Just tried this as I was getting almost continual black screen of death. Straightaway a noticeable difference, haven't a crash yet. Windows 7, all the latest versions of the standalone, Java etc.

Make this sticky!!