1

Are there any tools/plugins that can identify the profile like memory, cpu and other usage information on each request in grails web application.

An Ish A
  • 711
  • 5
  • 18
  • Mainly i need to find memory usage for each action in application. – An Ish A Jan 14 '15 at 11:29
  • Most of tools could show mem usage per method/class/etc, but it's really hard to distinguish which part of this belongs to which request, especially if you more that one simultaneous requests – Igor Artamonov Jan 14 '15 at 12:24
  • have you looked into melody? http://grails.org/plugin/grails-melody – cfrick Jan 14 '15 at 12:41
  • @IgorArtamonov suggest one tool for mem usage. i have tried grailsmelody for this, but it overrides grails datasource. so application is not running fine. – An Ish A Jan 14 '15 at 12:41
  • @cfrick melody overrides grails datasource. so application is not working fine. and show an error org.apache.commons.dbcp.BasicDataSource.getInitialSize() – An Ish A Jan 14 '15 at 12:45
  • @AnIshA i was using only standard VisualVM, but there're other tools, like YouKit or JProfiler. can't say which is better – Igor Artamonov Jan 14 '15 at 13:19

1 Answers1

0

Try this:

public class CrunchifyJVMParameters {


    public static void main(String[] args) {

        int mb = 1024 * 1024; 

        // get Runtime instance
        Runtime instance = Runtime.getRuntime();

        System.out.println("***** Heap utilization statistics [MB] *****\n");

        // available memory
        System.out.println("Total Memory: " + instance.totalMemory() / mb);

        // free memory
        System.out.println("Free Memory: " + instance.freeMemory() / mb);

        // used memory
        System.out.println("Used Memory: "
                + (instance.totalMemory() - instance.freeMemory()) / mb);

        // Maximum available memory
        System.out.println("Max Memory: " + instance.maxMemory() / mb);
    }
}

Source https://crunchify.com/java-runtime-get-free-used-and-total-memory-in-java/

Pablo Pazos
  • 3,080
  • 29
  • 42