Compiling in Memory

I am reading a book Java 6 Platform Revealed which describes using of Compiler API. Unfortunately Compiler API was changed during development of Mustang.
This sample stopped to work although I renamed names of classes into new ones.
I am able to compile the source of HelloWorld class, but I don't know how to invoke a new instance of this successfully compiled class (I get permanent ClassNotFoundException).
How to get it work?
Thank you for your help
Cavity
PS. I don't want to use extern files (as described here http://javainsel.blogspot.com/2006/03/example-for-using-java-6-compiler-api.html), I would like to make it as fast as possible (=in memory).
Java SE 6 final
import javax.tools.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.util.Arrays;
public class CompileSource {
    private CompileSource() {
    public static void main(String args[]) throws IOException {
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        DiagnosticCollector<JavaFileObject> diagnostics =
                new DiagnosticCollector<JavaFileObject>();
        StringWriter writer = new StringWriter();
        PrintWriter out = new PrintWriter(writer);
        out.println("public class HelloWorld {");
        out.println("  public static void main(String args[]) {");
        out.println("    System.out.println(\"Hello, World\");");
        out.println("  }");
        out.println("}");
        out.close();
        JavaFileObject file =
                new JavaSourceFromString("HelloWorld", writer.toString());
        Iterable<? extends JavaFileObject> compilationUnits =
                Arrays.asList(file);
        JavaCompiler.CompilationTask task = compiler.getTask(
                null, null, diagnostics, null, null, compilationUnits);
        boolean success = task.call();
        for (Diagnostic diagnostic : diagnostics.getDiagnostics())
            System.console().printf(
                    "Code: %s%n" +
                            "Kind: %s%n" +
                            "Position: %s%n" +
                            "Start Position: %s%n" +
                            "End Position: %s%n" +
                            "Source: %s%n" +
                            "Message:  %s%n",
                    diagnostic.getCode(), diagnostic.getKind(),
                    diagnostic.getPosition(), diagnostic.getStartPosition(),
                    diagnostic.getEndPosition(), diagnostic.getSource(),
                    diagnostic.getMessage(null));
        System.out.println("Success: " + success);
        if (success) {
            try {
                System.out.println("-----Output-----");
                Class.forName("HelloWorld").getDeclaredMethod("main",
                        new Class[]{String[].class}).invoke(null, new Object[]{null});
                System.out.println("-----Output-----");
            } catch (ClassNotFoundException e) {
                System.err.println("Class not found: " + e);
            } catch (NoSuchMethodException e) {
                System.err.println("No such method: " + e);
            } catch (IllegalAccessException e) {
                System.err.println("Illegal access: " + e);
            } catch (InvocationTargetException e) {
                System.err.println("Invocation target: " + e);
    static public class JavaSourceFromString extends SimpleJavaFileObject {
        final String code;
        JavaSourceFromString(String name, String code) {
            super(URI.create(
                    "string:///" + name.replace('.', '/') + Kind.SOURCE.extension),
                    Kind.SOURCE);
            this.code = code;
        @Override
        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
            return code;
}Message was edited by:
Cavity

This is exactly what I was looking for the whole day. Thank you very much Peter.
Unfortunately I cannot give you your deserved dukes :-((.
This forum is buggy, i cannot log in under my previous account :-((( and reseting password without "security" question does not work either.

Similar Messages

  • Compiling (in memory) and Loading classes on fly

    Hiya,
    I have following classes:
    public class Vehicle {Protected Sting reg;}
    public class Car extends Vehicle
    (public void print(){System.out.println(reg);}}
    These classes (or different ones) are stored in one text file. The program must read these files then compile and load them dynamically in memory.
    The link below authored by DCHSW deals with one class only (compile and loading) however it fails with more then one class particularly when it is subclassed.
    http://forum.java.sun.com/thread.jsp?thread=347467&forum=4&message=1439418
    How can we get the code mentioned at link above to compile (in memory) and load subclasses like the ones mentioned above.
    Thanks
    Derik

    Hiya,
    I have following classes:
    public class Vehicle {Protected Sting reg;}
    public class Car extends Vehicle
    (public void print(){System.out.println(reg);}}
    These classes (or different ones) are stored in one
    text file. The program must read these files then
    compile and load them dynamically in memory.
    The link below authored by DCHSW deals with one class
    only (compile and loading) however it fails with more
    then one class particularly when it is subclassed.
    Read the following post for full description of the problem
    http://forum.java.sun.com/thread.jsp?forum=4&thread=417724
    Any ideas?
    Thanks
    Derik
    http://forum.java.sun.com/thread.jsp?thread=347467&foru
    =4&message=1439418
    How can we get the code mentioned at link above to
    compile (in memory) and load subclasses like the ones
    mentioned above.
    Thanks
    Derik

  • A Question for the Cracks - dynamic Compilation in Memory?

    HI
    i just wondered if it is possible to compile a java source file during runtime in MEMORY, means, without writing the class file to the filesystem but being able to create an instance of that compiled class file.
    I guess, theoreticaly this must be possible, since i could try to take the output of the compiler as an input stream in my application an save that stream as a String (or somehow different) and then try to create the an instance using classloader and serialization (somehow.... problem is, i don't know yet how this excatly could be done).
    I know, that question sounds a little bit strange, but I'm just thinking about a licening methode and this could do a very important part of it.
    So i would be very thankfull for any comment about this idea!
    josh

    Yeah, but here's the thing. If you provide the source files to the program, then you've put the thief one step closer to having your program (they don't have to decompile it.) Even if you encrypt the source, once they've decrypted that they're still one step closer than if you just encrypted the bytecode.
    In the encrypted class file solution, if the user doesn't have a legal license, they cannot run the program, because they cannot decrypt the classes. They have the encryption algorithm, but since they don't have a private key (which is in the license file) they can't load the code.
    The license also, would be one-license-per-user, with a multitude of different licenses able to decrypt the same encrypted classes. If you don't want a particular party to have the program, you just don't give them a key, or give them a key which decrypts only a certain set of classes (effectively providing them with a functional demo.)
    Even once the user has a license and your algorithm though, it still isn't trivial for them to make decrypted .class files out of them though, since your algorithm will load the classes as soon as they're created. They'd have to decompile and hack up the decryption code to write the classes back to files also.
    You could probably also figure out some way to stamp an ID on each decrypted class at runtime, so you can tell which user is running the program so if someone does distribute decrypted versions of the classes, you can tell which user did it and start legal proceedings. :-)

  • Dynamic compilation in memory

    Hello,
    I have used javax.tools.ToolProvider to compile a simple class that comes from a CharSequence object in memory, and it works just fine.
    Now, I need to reference another class that comes also from a CharSequence object in memory. Which method in the ForwardingJavaFileManager I should override to make this class available to the main class.
    Thank you
    The class I need to reference is in class (.class) format not the java source format (.java).
    Edited by: Gen.Java on Apr 23, 2013 2:05 AM

    CharSequence src = "public class DynaClass {public String toString (){return"hello";}}";Using javax.tools API, this compiles just fine. However,the following does not, complaining that it cannot find the class "another". The bytecode for the class "another" is in memory (not the file system). I just need to make it available to the main class "DynaClass".
    CharSequence src = "public class DynaClass {public String toString (){return new another().get();}}";The following is my code:
    import java.util.*;
    import javax.tools.*;
    import java.io.*;
    public class DynaCompTest
    public static void main(String[] args) throws Exception
    JavaCompiler         compiler;
    ClassFileManager     fileManager;
    List<JavaFileObject> jfiles;
    CharSequence         src;
    String               fullName;
    fullName = "DynaClass";
    src      = "public class DynaClass {public String toString (){return"hello";}}";
    compiler    = ToolProvider.getSystemJavaCompiler ();
    fileManager = new ClassFileManager ( compiler.getStandardFileManager(null, null, null) );
    jfiles      = new ArrayList<JavaFileObject>();
    jfiles.add  ( new CharSequenceJavaFileObject(fullName,src) );
    compiler.getTask ( null, fileManager, null, null, null, jfiles).call ();
    import java.net.*;
    import javax.tools.*;
    public class CharSequenceJavaFileObject extends SimpleJavaFileObject
    private CharSequence content;
    public       CharSequenceJavaFileObject (
    String       className,
    CharSequence content                    )
    super      ( URI.create("string:///" + className.replace('.', '/')+ Kind.SOURCE.extension), Kind.SOURCE);
    this.content = content;
    @Override
    public CharSequence getCharContent       (
    boolean             ignoreEncodingErrors )
    return content;
    import java.security.*;
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import javax.tools.*;
    import javax.tools.JavaFileObject.*;
    public class ClassFileManager extends ForwardingJavaFileManager<JavaFileManager>
    private final Map<String,JavaClassObject> fileObjects;
    public                  ClassFileManager (
    StandardJavaFileManager standardManager  )
    super       ( standardManager );
    fileObjects = new HashMap<String,JavaClassObject>();
    @Override
    public ClassLoader getClassLoader (
    Location           location       )
    return new ClassLoader() {
               @Override
               protected Class<?> findClass(String name) throws ClassNotFoundException {
                    JavaClassObject jco;
                    jco      = fileObjects.get(name);
                    byte[] b = jco.getByteCode();
                    return super.defineClass(name, b, 0, b.length);
    @Override
    public JavaFileObject getJavaFileForOutput (
    Location              location,
    String                className,
    Kind                  kind,
    FileObject            sibling              ) throws IOException
    JavaClassObject jco;
    jco             = new JavaClassObject(className, kind);
    fileObjects.put ( className,jco );
    return jco;
    import java.net.*;
    import java.io.*;
    import javax.tools.*;
    public class JavaClassObject extends SimpleJavaFileObject
    protected final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    public JavaClassObject (
    String className,
    Kind   kind            )
    super ( URI.create("string:///" + className.replace('.', '/')+ kind.extension), kind );
    public byte[] getByteCode ()
    return bos.toByteArray();
    @Override
    public OutputStream openOutputStream () throws IOException
    return bos;
    }

  • Access jar file from in-memory classes...

    I have some classes that I compile to memory and everything works fine until one class that must access some external jar files. I have been unable to access those jar files from disk after trying every suggestion using URLClassLoader. I even tried someone's example to hack the SystemClassLoader which properly adds the jar file paths, but still they can't be seen. The only way it works is if I put the files in the jdk/jre/lib/ext directory. Then everything works fine. There must be a way to load the jar files in memory as well as the class files so they can be accessible. Has anyone done anything like this? Is it possible? Even though the class files are in memory, why would the jar files not be seen even when they are added to the same URLClassLoader's URL's. Thanks.

    Sorry that wasn't clear. What I mean is that the classes are compiled to byte code directly to memory and no physical .class file is created. Yes, I'm using my own ClassLoader that extends URLClassLoader and I'm setting the parent to ClassLoader.getSystemClassLoader(). I also should mention that I'm doing this inside a Netbeans module that is part of a Netbeans Platform application. I don't know why that should matter though, since I'm trying to do everything in memory without creating the physical files. Thanks.

  • Memory leaks in my application

    Hi all,
    My application is running well but the memory used by my application is not properly released. If my application is kept running for a day ..then the total system memory is used and server got struckup. can any body help me how can trace for the memory leaks in my application.
    Thanks in advance.
    Santhosh.gandhe

    What version of JDK are you running?
    The Java compiler leaks memory each time a class is compiled. Web applications containing hundreds of JSP files may as a result trigger out of memory errors once a significant number of pages have been accessed. The memory can only be freed by stopping Tomcat and then restarting it.
    The JSP command line compiler (JSPC) can also be used to recompile the JSPs.
    Note: This issue has been fixed in Sun JDK 1.4.x.

  • Is there a 64-bit version of the CC compiler itself?

    Hello,
    We have a large (~4k lines) .cpp file which brings in a very large number of templates. On our v440 we see the compiler using more and more memory until it reaches 2Gb when it falls over with the message
    "Insufficient memory is available for compilation to continue."
    sun02% uname -a
    SunOS sun02 5.8 Generic_117350-05 sun4u sparc SUNW,Sun-Fire-V440
    sun02% CC -V
    CC: Sun C++ 5.8 Patch 121017-02 2006/04/19
    sun02% file /opt/v11/SUNWspro/bin/CC
    /opt/v11/SUNWspro/bin/CC: ELF 32-bit MSB executable SPARC32PLUS Version 1, V8+ Required, dynamically linked, stripped
    Is there a 64-bit version of the compiler which could handle code of this size? The large .cpp will be very difficult to split up.
    Interestingly, on our Xeon-based box running Solaris 10, the compilation is very very slow, but does complete OK.
    sun03% uname -a
    SunOS sun03 5.10 Generic_118855-33 i86pc i386 i86pc
    sun03% CC -V
    CC: Sun C++ 5.8 Patch 121018-10 2007/02/21
    sun03% file /opt/v11/SUNWspro/bin/CC
    /opt/v11/SUNWspro/bin/CC: ELF 32-bit LSB executable 80386 Version 1 [FPU], dynamically linked, stripped
    Thanks
    -- Steve

    Unfortunately, there is no 64-bit version of the compiler.
    Some things you can try:
    Reduce the size of individual compilation units (the total amount of source code seen by the compiler in one compilation run).
    Re-factor very large functions into smaller ones. During optimized compilation, the memory usage and compilation time is super-linear in the number of basic blocks in one function.
    Reduce the optimization level.
    If you have a support contract with Sun, please file a bug report via your support channel. If not, please file a bug report at bugs.sun.com.

  • Oracle 8.1.5 installation probelm on linux 7.3

    Please tell me about how to intstall oracle 8.1.5 on linux 7.3. without compiling kernel (MEMORY parameter), i try to install. But the error message like
    "cannot find the class oracle.sysman.oii.installer"
    etc..
    appear to me.
    now i am fully dtrucked. what to do ?

    newbie (guest) wrote:
    : Hi, All
    : I tried to install oracle 8.1.5 on RH6.0,
    : and I download the patch for enlightment,
    : the installation works well until CREATE DATABASE.
    : I got the error message "ORA-01012 not logged on".
    : Does anybody know what's the problem?
    : Thanks,
    Hi,
    try to
    export NLS_LANG=american
    In my case it helped. I described the strange behaviour of
    svrmgrl in detail in another post.
    Greetings
    Rolf
    null

  • How to speed up a Java application?

    As I learn more about Java, I realize that one of the main drawbacks compared to other languages is its speed. I have however heard that once the program is compiled once, it is "nearly as fast as C++" as long as it remains in memory.
    So the question to you all is, are there ways get an Java application compiled in memory and ensure that it remains in memory, and therefore get it as fast or faster than C++ or other lower level languages?
    Thanks,
    Nick

    Three items:
    This online book on performance: http://java.sun.com/docs/books/performance/
    Look into the -server option of the jvm "java -server"
    Check out the extensive performance documentation here at the Sun site - click on "Documetation" at the left
    This is only a small start into what's available on the subject, some searching using the site's seach engine (at the upper right corner) and Google will produce many more items of value.

  • VisualVM not starting correctly

    I have on some Linux servers a weird behaviour of jvisualvm.
    Java --> jdk1.6.0_43
    Linux + X11-Xming for graphics.
    The first time I start the tool, it starts coorectly. Then I close the tool and restart, and from then on I see the logo dialog, and then the tool seems to hang.
    I see two processes running
    root     31369 29806  0 10:41 pts/2    00:00:00 /bin/bash ./../lib/visualvm//platform/lib/nbexec --jdkhome ./.. --branding visualvm --clusters ./../lib/visualvm//visualvm:./../lib/visualvm//profiler: --userdir /root/.visualvm/7 -J-client -J-Xms24m -J-Xmx256m -J-Dsun.jvmstat.perdata.syncWaitMs=10000 -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.d3d=false
    root     31465 31369  0 10:41 pts/2    00:00:08 /opt/jdk6/bin/java -Djdk.home=/opt/jdk6 -classpath /opt/jdk6/lib/visualvm/platform/lib/boot.jar:/opt/jdk6/lib/visualvm/platform/lib/org-openide-modules.jar:/opt/jdk6/lib/visualvm/platform/lib/org-openide-util.jar:/opt/jdk6/lib/visualvm/platform/lib/org-openide-util-lookup.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/boot_ja.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/boot_zh_CN.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-modules_ja.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-modules_zh_CN.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-util_ja.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-util-lookup_ja.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-util-lookup_zh_CN.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-util_zh_CN.jar:/opt/jdk6/lib/dt.jar:/opt/jdk6/lib/tools.jar -Dnetbeans.dirs=./../lib/visualvm//visualvm:./../lib/visualvm//profiler: -Dnetbeans.home=/opt/jdk6/lib/visualvm/platform -client -Xms24m -Xmx256m -Dsun.jvmstat.perdata.syncWaitMs=10000 -Dsun.java2d.noddraw=true -Dsun.java2d.d3d=false -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/root/.visualvm/7/var/log/heapdump.hprof org.netbeans.Main --userdir /root/.visualvm/7 --branding visualvm
    Before starting I checked if the lock file is cleared and this is the case.
    The messages.log contains:
    >Log Session: Wednesday, June 26, 2013 11:00:55 AM CEST
    >System Info:
      Product Version         = Java VisualVM
      Operating System        = Linux version 2.6.18-194.26.1.0.1.el5 running on amd64
      Java; VM; Vendor        = 1.6.0_43; Java HotSpot(TM) 64-Bit Server VM 20.14-b01; Sun Microsystems Inc.
      Runtime                 = Java(TM) SE Runtime Environment 1.6.0_43-b01
      Java Home               = /opt/jdk1.6.0_43/jre
      System Locale; Encoding = en_US (visualvm); UTF-8
      Home Directory          = /root
      Current Directory       = /opt/jdk1.6.0_43/bin
      User Directory          = /root/.visualvm/7
      Installation            = /opt/jdk6/lib/visualvm/visualvm
                                /opt/jdk6/lib/visualvm/profiler
                                /opt/jdk6/lib/visualvm/platform
      Boot & Ext. Classpath   = /opt/jdk1.6.0_43/jre/lib/resources.jar:/opt/jdk1.6.0_43/jre/lib/rt.jar:/opt/jdk1.6.0_43/jre/lib/sunrsasign.jar:/opt/jdk1.6.0_43/jre/lib/jsse.jar:/opt/jdk1.6.0_43/jre/lib/jce.jar:/opt/jdk1.6.0_43/jre/lib/charsets.jar:/opt/jdk1.6.0_43/jre/lib/modules/jdk.boot.jar:/opt/jdk1.6.0_43/jre/classes:/opt/jdk1.6.0_43/jre/lib/ext/localedata.jar:/opt/jdk1.6.0_43/jre/lib/ext/sunpkcs11.jar:/opt/jdk1.6.0_43/jre/lib/ext/sunjce_provider.jar:/opt/jdk1.6.0_43/jre/lib/ext/dnsns.jar
      Application Classpath   = /opt/jdk6/lib/visualvm/platform/lib/boot.jar:/opt/jdk6/lib/visualvm/platform/lib/org-openide-modules.jar:/opt/jdk6/lib/visualvm/platform/lib/org-openide-util.jar:/opt/jdk6/lib/visualvm/platform/lib/org-openide-util-lookup.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/boot_ja.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/boot_zh_CN.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-modules_ja.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-modules_zh_CN.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-util_ja.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-util-lookup_ja.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-util-lookup_zh_CN.jar:/opt/jdk6/lib/visualvm/platform/lib/locale/org-openide-util_zh_CN.jar:/opt/jdk6/lib/dt.jar:/opt/jdk6/lib/tools.jar
      Startup Classpath       = /opt/jdk6/lib/visualvm/platform/core/org-openide-filesystems.jar:/opt/jdk6/lib/visualvm/platform/core/core.jar:/opt/jdk6/lib/visualvm/platform/core/locale/org-openide-filesystems_ja.jar:/opt/jdk6/lib/visualvm/platform/core/locale/core_ja.jar:/opt/jdk6/lib/visualvm/platform/core/locale/org-openide-filesystems_zh_CN.jar:/opt/jdk6/lib/visualvm/platform/core/locale/core_zh_CN.jar:/opt/jdk6/bin/../lib/visualvm/visualvm/core/com-sun-tools-visualvm-modules-startup.jar:/opt/jdk6/bin/../lib/visualvm/visualvm/core/locale/.svn_zh_CN.jar:/opt/jdk6/bin/../lib/visualvm/visualvm/core/locale/core_visualvm.jar:/opt/jdk6/bin/../lib/visualvm/visualvm/core/locale/com-sun-tools-visualvm-modules-startup_zh_CN.jar:/opt/jdk6/bin/../lib/visualvm/visualvm/core/locale/.svn_ja.jar:/opt/jdk6/bin/../lib/visualvm/visualvm/core/locale/com-sun-tools-visualvm-modules-startup_ja.jar
    INFO [org.netbeans.core.startup.NbEvents]: Turning on modules:
      org.openide.util.lookup [8.3.1 110131-9c8b3bfb3a1e]
      org.openide.util [8.6.1 110131-9c8b3bfb3a1e]
      org.openide.modules [7.17.2 110131-9c8b3bfb3a1e]
      org.openide.awt [7.23.1 110131-9c8b3bfb3a1e]
      org.netbeans.api.progress/1 [1.20.2 110131-9c8b3bfb3a1e]
      org.openide.dialogs [7.15.1 110131-9c8b3bfb3a1e]
      org.openide.nodes [7.16.1 110131-9c8b3bfb3a1e]
      org.openide.windows [6.33.1 110131-9c8b3bfb3a1e]
      org.openide.filesystems [7.38.2 110131-9c8b3bfb3a1e]
      org.netbeans.modules.editor.mimelookup/1 [1.16.1 110131-9c8b3bfb3a1e]
      org.openide.text [6.30.1 110131-9c8b3bfb3a1e]
      org.netbeans.swing.tabcontrol [1.21.1 110131-9c8b3bfb3a1e]
      org.netbeans.swing.outline [1.9.1 110131-9c8b3bfb3a1e]
      org.openide.explorer [6.28.2 110131-9c8b3bfb3a1e]
      org.openide.actions [6.16.1 110131-9c8b3bfb3a1e]
      org.openide.io [1.23.1 110131-9c8b3bfb3a1e]
      org.netbeans.core.io.ui/1 [1.8.1 110131-9c8b3bfb3a1e]
      org.netbeans.bootstrap/1 [2.33.1 110131-9c8b3bfb3a1e]
      org.netbeans.core.startup/1 [1.25.2 110131-9c8b3bfb3a1e]
      org.netbeans.modules.autoupdate.services [1.20.1 110131-9c8b3bfb3a1e]
      org.netbeans.spi.quicksearch [1.6.1 110131-9c8b3bfb3a1e]
      org.netbeans.modules.queries/1 [1.19.1 110131-9c8b3bfb3a1e]
      org.openide.loaders [7.16.1 110131-9c8b3bfb3a1e]
      org.netbeans.modules.keyring [1.1.2 110131-9c8b3bfb3a1e]
      org.netbeans.swing.plaf [1.16.1 110131-9c8b3bfb3a1e]
      org.netbeans.core/2 [3.20.2 110131-9c8b3bfb3a1e]
      org.netbeans.modules.options.api/1 [1.18.1 110131-9c8b3bfb3a1e]
      org.netbeans.modules.autoupdate.ui [1.16.1 110301-30e4969ec30f]
      org.netbeans.modules.print [7.5.1 110201-9c8b3bfb3a1e]
      org.netbeans.lib.profiler/1 [1.10.2 110225-30e4969ec30f]
      org.netbeans.lib.profiler.charts/1 [1.6.1 110201-f994a39d39de]
      org.netbeans.lib.profiler.ui/1 [1.9.2 110225-30e4969ec30f]
      com.sun.tools.visualvm.uisupport/0 [1.0 110325]
      org.netbeans.lib.profiler.common/1 [1.10.2 110225-30e4969ec30f]
      org.netbeans.api.annotations.common/1 [1.5.1 110131-9c8b3bfb3a1e]
      org.netbeans.modules.profiler.oql/0 [0.5.1 110225-30e4969ec30f]
      org.openide.execution [1.18.1 110131-9c8b3bfb3a1e]
      org.netbeans.modules.profiler/1 [1.17.2 110225-30e4969ec30f]
      org.netbeans.modules.sendopts/2 [2.9.1 110201-9c8b3bfb3a1e]
      com.sun.tools.visualvm.core/0 [1.4 110325]
      com.sun.tools.visualvm.host/0 [1.0 110325]
      com.sun.tools.visualvm.application/0 [1.4 110325]
      com.sun.tools.visualvm.tools/0 [1.2 110325]
      com.sun.tools.visualvm.attach/0 [1.1 110325]
      com.sun.tools.visualvm.profiling/0 [1.0 110325]
      com.sun.tools.visualvm.profiler/0 [1.1 110325]
      org.netbeans.modules.settings/1 [1.26.1 110131-9c8b3bfb3a1e]
      com.sun.tools.visualvm.coredump/0 [1.0 110325]
      com.sun.tools.visualvm.heapdump/0 [1.1 110325]
      com.sun.tools.visualvm.threaddump/0 [1.0 110325]
      com.sun.tools.visualvm.sampler [2.0 110325]
      com.sun.tools.visualvm.charts/0 [1.0 110325]
      com.sun.tools.visualvm.application.views/0 [1.0 110325]
      org.netbeans.modules.progress.ui [1.12.1 110201-9c8b3bfb3a1e]
      org.netbeans.core.windows/2 [2.21.1 110131-9c8b3bfb3a1e]
      org.netbeans.modules.editor.mimelookup.impl/1 [1.9.1 110131-9c8b3bfb3a1e]
      com.sun.tools.visualvm.host.remote/0 [1.0 110325]
      com.sun.tools.visualvm.jmx/0 [1.2 110325]
      com.sun.tools.visualvm.sa/0 [1.0 110325]
      com.sun.tools.visualvm.jvm/0 [1.1 110325]
      com.sun.tools.visualvm.modules.startup [1.0 110325]
      org.netbeans.core.ui/1 [1.22.1 110131-9c8b3bfb3a1e]
      com.sun.tools.visualvm.host.views/0 [1.0 110325]
      com.sun.tools.visualvm.modules.appui [1.0 110325]
      org.netbeans.modules.masterfs/2 [2.25.2 110201-9c8b3bfb3a1e]
      com.sun.tools.visualvm.jvmstat/0 [1.0 110325]
    Any idea why I see this weird behaviour?
    Walter

    More information
    When the application starts correctly the following diagnostic info is given
    Diagnostic information
    Input arguments:
      -Djdk.home=/usr/java/jdk1.6.0_24
      -Dnetbeans.dirs=/usr/java/jdk1.6.0_24/bin/../lib/visualvm//visualvm:/usr/java/jdk1.6.0_24/bin/../lib/visualvm//profiler:
      -Dnetbeans.home=/usr/java/jdk1.6.0_24/lib/visualvm/platform
      -Xms24m
      -Xmx256m
      -Dsun.jvmstat.perdata.syncWaitMs=10000
      -Dsun.java2d.noddraw=true
      -Dsun.java2d.d3d=false
      -XX:+HeapDumpOnOutOfMemoryError
      -XX:HeapDumpPath=/root/.visualvm/6u23/var/log/heapdump.hprof
    Compiler: HotSpot 64-Bit Server Compiler
    Heap memory usage: initial 24.0MB maximum 247.5MB
    Non heap memory usage: initial 23.2MB maximum 130.0MB
    Garbage collector: Copy (Collections=9 Total time spent=0s)
    Garbage collector: MarkSweepCompact (Collections=1 Total time spent=0s)
    Classes: loaded=4051 total loaded=4051 unloaded 0
    INFO [org.netbeans.core.ui.warmup.DiagnosticTask]: Total memory 4,141,666,304
    INFO [null]: Total physical memory 4,141,666,304
    and this is NOT the case when the application hangs at startup.
    I tried other JDK version, and same there. Works once, .visualvm is created inside the $HOME location. Close the tool and restart, then it hangs at startup.
    Walter

  • Strange output from jrcmd print_memusage (R28)

    Hi guys,
    my jrcmd print_memusage tells me that my my heap is exactly the same size as my 'Compiled code' memory space:
    Total mapped 3709432KB (reserved=1053884KB)
    - Java heap 1048576KB (reserved=0KB)
    - GC tables 35084KB
    - Thread stacks 46848KB (#threads=162)
    - Compiled code 1048576KB (used=50879KB)
    - Internal 904KB
    - OS 64836KB
    - Other 641440KB
    - Classblocks 47616KB (malloced=47354KB #116850)
    - Java class data 772096KB (malloced=772015KB #557889 in 116850 classes)
    - Native memory tracking 3456KB (malloced=1451KB #10)
    This seems very weird to me, why would these 2 things be exactly the same?

    seems like a large amount of memory for compiled code but thanks for the response. Good to know the result is a sane one.

  • Matlab code much slower in Labview MatlabScript than in Matlab

    I was using an algorithm written in Matlab that executed in less than 2 seconds. Now I need to use it within a Labview program and I am using Matlab script with the same algorithm, but it lasts 10 times longer than in Matlab. Is this normal? Thank you!

    How do you know that it is 10 times? Did you create a benchmark?
    What are the conditions for the benchmark? Can you provide the code for it?
    I am asking this because if you create the VI and put the m-script in the script node, and then press run (looking on the watch) and wait for the VI to finish, you "benchmarked" compile times, memory allocation as well as the complete VI's execution (including the script node of course). I doubt that this will ever be comparable to the "benchmark" in MatLab.
    If you provide your VI, we might also be able to give some hints to increase performance.
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • When and why do we disable/retire signatures

    The question comes up every now and again - when do we (IPS signature team) disable or retire signatures.
    Remember that there is a difference between disabled and retired. Essentially:
    Disabled/enabled - turns the written alert off/on.
    Retired/active - signature "does not"/"does" get compiled in memory.
    As a rule of thumb, we will release signatures active and enabled.
    We may release a signature disabled by default if the vulnerability is severe, but it is unlikely that the software is in wide-spread use.
    We may disable a signature that in certain environments would fire excessively on benign traffic.
    We will generally release policy signatures (for example, MSN traffic, AIM traffic, p2p, etc.) as disabled by default since they alert on legitimate and normally expected traffic for that application/protocol.
    It is up to the organization to enable the alerts if they care too.
    We will disable and retire signatures where the vulnerability is 18+ months old, is not a protocol vulnerability (tcp, udp, ip, http, etc.), and has had no active exploitation in the past 6 months.
    There will always be exceptions, but this covers most scenarios.

    For any Cisco folks around here ...
    This was written ~2 years ago, explaining the process/rationale behind default signature status configurations. 
    Can you please indicate if the information is this post is still correct?  Has anything changed regarding your SOP for default signature configurations?
    Thanks.

  • OpenSparc used in a multi processor platform?

    Hi,
    I'd like to know if it is possible to implement two OpenSparcT1 into two different FPGAs so as to have a multiprocessor platform. Is there a pre-built platform that handles memories, communication between processors and between memories and processors and all software partitionning for the applications to be run on the processors?
    Thanks for answering,
    Regards.

    The current design assumes the OpenSPARC board (ML505-XC5VLX110T). So the pinout and everything is set assuming that platform. If you go to another platform, you'll need to make changes to work with that platform. Among other things, you may need to use a different memory controller, or at least compile the memory controller with different parameters. Then you'll need to figure out how to communicate between the two OpenSPARC cores. If the FPGA is large enough to fit two OpenSPARC cores, then the communication between the cores gets easier. Otherwise, you'll have to evaluate what options you have on the target platform for communicating between two FPGAs on a board, or between two Boards. It may be that the Xilinx Aurora block may still work, even though it is running over a different physical interface. Of course, if your platform is an FPGA from a different manufacturer, you'll have to start from the beginning with all-new IP.
    The current two core system is implemented with one core on each FPGA board. On each board, the bit file includes the OpenSPARC core, the Xilinx MicroBlaze controller, memory controller, serial port, and the Aurora interface, which connects to the other board. Different software is run on the board, however. On the slave board, the firmware simply forwards memory requests to the master board. Memory on this board is mostly unused, with only a small part being used for the MicroBlaze code and data. On the Master board, the firmware processes all memory requests, from the local core, as well as the remote core. On this board, memory is partitioned with a small part being used for the MicroBlaze code, about half being used for the OpenSPARC memory space, and the other half being used for the OpenSPARC RAM disk image.
    The next question was about runtime scheduling of an executable. If the executable has only a single thread of execution, it will run on one core, one hardware thread, and cannot be partitioned between two cores, or even two hardware threads. If some mechanism has been used to create multi-threaded execution in the program (like explicit programming using pthreads, or maybe OpenMP), then at run-time, the operating system (OpenSolaris) will schedule the different threads of the program onto different hardware threads or different cores. If you try to run a program directly under Hypervisor, without an operating system, then all the partitioning would have to be done explicitly in the program itself.
    Hope this helps,
    formalGuy

  • Why are object alloc delays occuring outside of GC?

    Hi
    I'm currently tuning an application which has a low latency transaction requirement (sub 5ms ideally), hence we're using JRockit RT with an 8ms deterministic strategy (we're not achieving 8ms GC pause, but some time ago we experimented and found this was a good setting for us).
    I'm currently focused on addressing latency spikes which we're hoping to bring down from many hundreds of ms to the order of 10-20ms. Many of the spikes are occurring during GC activity as one would expect, but I'm currently looking at some spikes outside of GC which I'm struggling to understand the cause of. What I seem to be seeing is object alloc delays which are occuring and then being resolved, but outside of any GC activity.
    For example, see the following snippet from the log. Cmd line params include:
    -Xverbose:memory,memdbg=debug,gcpause=debug,compaction,gcreport,refobj
    -Xgcprio:deterministic
    -Xpausetarget=8ms
    Version=
    java version "1.6.0_05"
    Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
    BEA JRockit(R) (build R27.6.0-50_o-100423-1.6.0_05-20080626-2104-linux-x86_64, compiled mode)
    [memory ][Wed May 26 12:31:38 2010][23134] Pause 'OC:Cleanup' took 0.179 ms (ended at 1545.738649 s).
    [memory ][Wed May 26 12:31:38 2010][23134] 1539.900-1545.738: GC 13279297K->11726889K (14680064K), sum of pauses 386.637 ms
    [memdbg ][Wed May 26 12:31:38 2010][23134] Page faults before GC: 1, page faults after GC: 1, pages in heap: 3670016
    [finaliz][Wed May 26 12:31:38 2010][23134] (OC) Pending finalizers 0->0
    [memdbg ][Wed May 26 12:31:38 2010][23134] Restarting of javathreads took 0.257 ms
    *[gcpause][Wed May 26 12:31:38 2010][23134] Thread "pool-1-thread-1" id=217 idx=0x36c tid=25388 was in object alloc 75.397 ms from 1546.387 s*
    [memdbg ][Wed May 26 12:34:04 2010][23134] GC reason: Other, cause: Memleak Request Data
    [memdbg ][Wed May 26 12:34:04 2010][23134] Stopping of javathreads took 0.817 ms
    [memdbg ][Wed May 26 12:34:04 2010][23134] old collection 38 started
    [memdbg ][Wed May 26 12:34:04 2010][23134] Alloc Queue size before GC: 0, tlas: 0, oldest: 0
    [memdbg ][Wed May 26 12:34:04 2010][23134] Compacting 1 heap parts at index 44 (type internal) (exceptional false)
    The above log segment shows the tail of a GC which has just completed, then an object alloc delay for 75ms for thread "pool-1-thread-1", and then a subsequent GC kicks in much later which I believe is unrelated. I have a JRA trace from the test which shows that the object alloc latency event occurred almost a full second after the completion of the GC activity - something you can't see from the above trace which has second resolution in the timestamp.
    What I'm unsure of is exactly how the object alloc delay can occur and then be rectified by the JVM outside of a GC. I understood the main cause of an object alloc latency event was that memory wasn't available (i.e. TLA does not have enough free space and a new TLA cannot be allocated) and that a GC would be required to free up memory to allow either a new TLA to be allocated or free up enough space in an existing one. We see an "object alloc" latency delay which follows the above pattern after every GC so I'm guessing it must somehow be related to the GC which has just finished, but I can't figure out how. My hope is to eliminate this kind of latency delay completely or at least down to single-figure ms delays.
    Perhaps the deterministic GC means some memory reclaim is happening in parallel outside of the reported GC activity, but I'd be very surprised if this was the reason as surely the collector would be reporting it's activity more fully. It's been a while since I've looked this closedly at GC so I may have forgotten something.
    Any help you can provide in working out how to address such latency spikes would be very helpful!
    Thanks
    Stuart

    I think the extra time is due to the compaction of the heap (which occurs after a garbage collection).
    Note also that a very low pausetarget can stress the garbage collector to less appreciated behavior, when the application and the hardware or not appropriate. If you look at the application about 30% live data or less at collection time is something your application should strive at. Running with more live data might break the deterministic behavior (depending on the hardware of course).
    You can tune compaction with the determistic collector as follows,
    MEASUREMENT_ARGS="-Xverbose:gc,gcpause,memdbg"
    export MEASUREMENT_ARGS
    USER_MEM_ARGS="${MEASUREMENT_ARGS} -Xms512m -Xmx1000m -Xns256m -Xgcprio:deterministic -XpauseTarget=30ms -XXgcThreads:2 -XXtlaSize:min=2k,preferred=16k -XXcompactSetLimitPerObject:500 -XXinitialPointerVectorSize:40 -XXmaxPooledPointerVectorSize:8000 -XXpointerMatrixLinearSeekDistance:5"
    export USER_MEM_ARGS
    The last four options are used to tune compaction for the deterministic collector. In optimizing compaction try to reduce object references, because when a object is moved during compaction its references must be updated. So moving an object with a lot of references is more costly than moving an object with a few references.
    Refer to http://otndnld.oracle.co.jp/document/products/jrockit/jrdocs/pdf/refman.pdf for more information.

Maybe you are looking for

  • Mail 2.0.5 CRASHES ON OPEN after Security Update 2005-009(Tiger Client)

    I'm trying to figure out how to fix this. I rebooted into a techtool pro e-drive and repaired permissions (as well as some other repairs to the drive, etc), but it still is crashing. I created a new user and opened mail just fine there. So... it is s

  • Steps to insert a clickTag in a Flash Banner with Flash MX 6 & Adobe CS3 Version

    Hi Folks I am very new to this forum + having a basic level of understanding with Flash Software (like Flash MX & Adobe CS3). By profession i am online trafficker, and because of the fact that our Flash Creative Designer has gone on a leave, i theref

  • Win7: Duplicate phone file folders in Explorer

    Hi, When using Windows 7 with it's native bluetooth stack + Ovi suite, you end up getting two file folders in the Explorer window: First one is a native Windows 7 feature, second one came after Ovi installation. Now while I really appreciate the fold

  • Removing Supervisor Password via WMI?

    Hello guys, I'm trying to remove our supervisor password from our computers using the WMI-interface (described here: http://support.lenovo.com/en_US/detail.page?LegacyDocID=MIGR-68488). It works fine when trying to change the password using the provi

  • 2008 iMac won't turn on after Mountain Lion installation

    I have a 2008 iMac with 6GB of RAM that was running on OS X 10.6.8 perfectly. Tonight I upgraded it to Mountain Lion. After the installation, my machine was running slower and a little choppy, especially when first opening programs, even though it me