Sign in to follow this  
joedobo

Help with getting JAMM to work.

Recommended Posts

I'd like to use this tool: https://github.com/jbellis/jamm

 

But I'm having trouble getting it to work. I need a step by step complete noob tutorial.

Here is what I did so far:

1. cloned the github project into a new Intellij projbect.

2. used ant and the included build.xml file to fetch external sources.

3. setup the project so it can build a artifact jar and artifact-built to make jamm.jar.

4. put that jamm.jar in my server directory.

 

Here is some print out info from the command window I use to launch modlauncher:

Quote

C:\Users\Jason\Documents\WU\WU-Server>modlauncher.bat

C:\Users\Jason\Documents\WU\WU-Server>if exist logging.properties set LOGGING=-Djava.util.logging.config.file=logging.properties

C:\Users\Jason\Documents\WU\WU-Server>set JAVA=java

C:\Users\Jason\Documents\WU\WU-Server>if exist runtime\bin\java.exe set JAVA=runtime\bin\java.exe

C:\Users\Jason\Documents\WU\WU-Server>if exist ..\runtime\bin\java.exe set JAVA=..\runtime\bin\java.exe

C:\Users\Jason\Documents\WU\WU-Server>runtime\bin\java.exe "-Dworkdir=C:\Users\Jason\Documents\WU\WU-Server" "-Djava.library.path=C:\Users\Jason\Documents\WU\WU-Server\nativelibs" -Djava.util.logging.config.file=logging.properties "-javaagent:C:\Users\Jason\Documents\WU\WU-Server\jamm.jar" -Xmn256M -Xms512m -Xmx2048m -XX:+OptimizeStringConcat -XX:+AggressiveOpts -jar modlauncher.jar
Error opening zip file or JAR manifest missing : C:\Users\Jason\Documents\WU\WU-Server\jamm.jar
Error occurred during initialization of VM
agent library failed to init: instrument

C:\Users\Jason\Documents\WU\WU-Server>

 

Here is modlauncher.bat

if exist logging.properties set LOGGING=-Djava.util.logging.config.file=logging.properties

set JAVA=java
if exist runtime\bin\java.exe set JAVA=runtime\bin\java.exe
if exist ..\runtime\bin\java.exe set JAVA=..\runtime\bin\java.exe

%JAVA% "-Dworkdir=%CD%" "-Djava.library.path=%CD%\nativelibs" %LOGGING% "-javaagent:C:\Users\Jason\Documents\WU\WU-Server\jamm.jar" -Xmn256M -Xms512m -Xmx2048m -XX:+OptimizeStringConcat -XX:+AggressiveOpts -jar modlauncher.jar  %* 

 

Maybe you know of an easy-to-use, super-noob-compliant, object memory inspection tool? 

 

edit...This has nothing to do with the WU server or WU code in any form. It is a request to help me get this third party tool to work. I have no idea why a WU moderator moved it here.

Edited by joedobo

Share this post


Link to post
Share on other sites

Another helpful thing related to this would a way to use debug breakpoints in the modloader related methods like onServerStarted() or init().

 

Here Bdew advised on one way to get the debugger to work: 

 

I've only been able to get that to work for a round about process: 1) make a proper java code method in my mode, 2) insert a call to that method in WU code somewhere, 3) add a breakpoint in the new method in my mod somewhere. 4) do stuff in game that would call the new method. This does work. I'd like to be able to use breakpoints earlier in execution.

 

I tried to configure some kind of remote-debug and Batch-execute (modlauncher.bat) in hopes Intellij would run mod launcher and immediately after attach the debugger. The server does start and run but my breakpoints aren't working.

 

An unrelated yet interesting side effect is I see is using the "Before launch" section I can compile the artifact.jar, run mod launcher, and have the information we usually see in a command prompt instead be Intellij frame, cool!

Edited by joedobo

Share this post


Link to post
Share on other sites

If i'm understanding correctly what the problem is... just change suspend=n to suspend=y in the command line (-agentlib:jdwp... section). It will make the process suspend immediately on startup and wait for a debugger to attach.

 

You will need to set breakpoints in the right places before attaching as it will un-suspend the process when you do.

 

Edit, the above is about your debugger problem, as for JAMM i never used it, but looking at the error it fails to find or to load the jar file...

 

Try:

  • re-downloading it
  • quoting just the path (-javaagent:"C:\....")
  • escaping the slashes (-javaagent:C:\\....)
  • flipping the slashes (-javaagent:C:/....)
  • putting the jar file in the same folder as wu...
Edited by bdew

Share this post


Link to post
Share on other sites

@bdewThank you!

I got the debugger to work. It seems to work well if I configure a JAR application in order to run modlauncher.jar. I run that and then run the remote debug tool.

 

Still not able to get JAMM to work...

[05:56:31 PM] SEVERE org.gotti.wurmunlimited.modloader.server.Listeners: ItemTemplatesCreatedListener handler for mod NatureSwayingMod failed
java.lang.IllegalStateException: Instrumentation is not set; Jamm must be set as -javaagent

 

I made a simple project to test JAMM ( Data.class is just a simple data holder object). It works and I used it similarly:

-javaagent:C:\Users\Jason\IdeaProjects\jamm\target\lib\jamm-0.3.1.jar

I'm guessing there are instrumentation conflicts happening. That error is thrown from inside JAMM.

 

public class App 
{
    static MemoryMeter memoryMeter = new MemoryMeter();
    static Random random = new Random();
    static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz";

    public static void main( String[] args )
    {
        Data data = new Data(random.nextLong(), random.nextInt(), ALPHABET);
        long size = memoryMeter.measure(data);
        IntStream.range(0, 100)
                .parallel()
                .forEach(value -> new Data(random.nextLong(), random.nextInt(), ALPHABET));
        int length = Data.objectHashMap.size();
        Data[] data1 = new Data[length];
        Data.objectHashMap.keySet().toArray(data1);
        long size2 = memoryMeter.measure(Data.objectHashMap.get(data1[random.nextInt(length)]));
        long size100 = memoryMeter.measure(Data.objectHashMap);

    }
}

Anyway my test answered my noob question regarding memory use and whether collections use object references or the memory footprint for the whole object.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this