{"id":127348,"date":"2024-11-15T11:11:00","date_gmt":"2024-11-15T09:11:00","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=127348"},"modified":"2024-11-14T09:37:39","modified_gmt":"2024-11-14T07:37:39","slug":"using-the-netbeans-profiler-programmatically-in-java","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html","title":{"rendered":"Using the NetBeans Profiler Programmatically in Java"},"content":{"rendered":"<p>This article explores how to use the NetBeans Profiler API to collect heap dumps, analyze memory usage, and inspect specific class instances programmatically within a Java application. We will explore using the NetBeans Profiler API to analyze performance metrics in Java applications programmatically. Rather than relying on VisualVM or GUI-based tools, programmatic profiling provides a flexible way to collect data from running applications and output it directly to the console or logs.<\/p>\n<h2 class=\"wp-block-heading\">1. Introduction to NetBeans Profiler API<\/h2>\n<p>The <a href=\"https:\/\/netbeans.apache.org\/tutorial\/main\/kb\/docs\/java\/profiler-intro\/\" target=\"_blank\" rel=\"noreferrer noopener\">NetBeans Profiler<\/a> is an effective tool for identifying performance bottlenecks, memory leaks, and usage patterns in Java applications. While its graphical interface is useful for in-depth profiling, accessing the profiler programmatically offers a streamlined, automated approach. The <a href=\"https:\/\/github.com\/apache\/netbeans\/tree\/master\/profiler\" target=\"_blank\" rel=\"noreferrer noopener\">NetBeans Profiler API<\/a>, available in the open-source <a href=\"https:\/\/github.com\/apache\/netbeans\" target=\"_blank\" rel=\"noreferrer noopener\">NetBeans repository<\/a>, enables programmatic access to profiling tools within the NetBeans IDE, allowing us to capture essential performance data directly in our code.<\/p>\n<h2 class=\"wp-block-heading\">2. Setting up a Sample Project<\/h2>\n<p>To begin, a simple Maven project should be set up, including the NetBeans Profiler API. If the profiler is not directly available, the NetBeans repository may need to be added. Here is an example <code>pom.xml<\/code> configuration:<\/p>\n<pre class=\"brush:xml\">\n    &lt;dependencies&gt;\n        &lt;!-- NetBeans Profiler dependency --&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;org.netbeans.modules&lt;\/groupId&gt;\n            &lt;artifactId&gt;org-netbeans-lib-profiler&lt;\/artifactId&gt;\n            &lt;version&gt;REPLACE_WITH_VERSION&lt;\/version&gt;\n        &lt;\/dependency&gt;\n    &lt;\/dependencies&gt;\n    &lt;repositories&gt;\n        &lt;repository&gt;\n            &lt;id&gt;netbeans&lt;\/id&gt;\n            &lt;name&gt;netbeans&lt;\/name&gt;\n            &lt;url&gt;http:\/\/bits.netbeans.org\/maven2&lt;\/url&gt;\n        &lt;\/repository&gt;\n    &lt;\/repositories&gt;\n<\/pre>\n<p>Replace <code>REPLACE_WITH_VERSION<\/code> with the appropriate version for the NetBeans Profiler API.<\/p>\n<h2 class=\"wp-block-heading\">3. Using the NetBeans Profiler API Programmatically<\/h2>\n<p>We will create a simple Java project that performs computational tasks and allocates memory, enabling us to analyze its performance using the NetBeans Profiler API. Let&#8217;s create a <code>Library<\/code> management system as an example, where each <code>Library<\/code> has books, sections, and other attributes. This class will simulate memory usage and provide data we can inspect in a heap dump.<\/p>\n<pre class=\"brush:java\">\npublic class Library {\n\n    private int id;\n    private String name;\n    private List&lt;String&gt; books = new ArrayList&lt;&gt;();\n    private List&lt;String&gt; sections = new ArrayList&lt;&gt;();\n\n    public Library(int id, String name) {\n        this.id = id;\n        this.name = name;\n    }\n\n    public void addBook(String bookName) {\n        books.add(bookName);\n    }\n\n    public void addSection(String sectionName) {\n        sections.add(sectionName);\n    }\n\n    public int getId() {\n        return id;\n    }\n\n    public void setId(int id) {\n        this.id = id;\n    }\n\n    public String getName() {\n        return name;\n    }\n\n    public void setName(String name) {\n        this.name = name;\n    }\n\n    public List&lt;String&gt; getBooks() {\n        return books;\n    }\n\n    public void setBooks(List&lt;String&gt; books) {\n        this.books = books;\n    }\n\n    public List&lt;String&gt; getSections() {\n        return sections;\n    }\n\n    public void setSections(List&lt;String&gt; sections) {\n        this.sections = sections;\n    } \n}\n<\/pre>\n<p>In this example:<\/p>\n<ul class=\"wp-block-list\">\n<li><code>Library<\/code> has attributes like <code>id<\/code>, <code>name<\/code>, <code>books<\/code>, and <code>sections<\/code>.<\/li>\n<li>The <code>addBook<\/code> and <code>addSection<\/code> methods allow adding books and sections to the library.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\">4. Taking a Heap Dump<\/h2>\n<p>To capture heap dumps programmatically, we will use a utility class named <code>HeapDumpUtility<\/code>. This class leverages the <code>HotSpotDiagnosticMXBean<\/code> from the <code>com.sun.management<\/code> package to trigger a heap dump at a specific point in the application.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java\">\nimport java.io.IOException;\nimport java.lang.management.ManagementFactory;\nimport com.sun.management.HotSpotDiagnosticMXBean;\n\npublic class HeapDumpUtility {\n\n    private static final String HOTSPOT_BEAN_NAME = \"com.sun.management:type=HotSpotDiagnostic\";\n    private static volatile HotSpotDiagnosticMXBean hotspotMBean;\n\n    public static void dumpHeap(String filename, boolean live) throws IOException {\n        initHotspotMBean();\n        hotspotMBean.dumpHeap(filename, live);\n    }\n\n    private static void initHotspotMBean() throws IOException {\n        if (hotspotMBean == null) {\n            synchronized (HeapDumpUtility.class) {\n                hotspotMBean = ManagementFactory.newPlatformMXBeanProxy(\n                        ManagementFactory.getPlatformMBeanServer(),\n                        HOTSPOT_BEAN_NAME,\n                        HotSpotDiagnosticMXBean.class);\n            }\n        }\n    }\n}\n<\/pre>\n<p>This <code>HeapDumperUtility<\/code> class uses the HotSpotDiagnosticMXBean to dump the heap into a file.<\/p>\n<h2 class=\"wp-block-heading\">5. Analyzing the Heap Dump<\/h2>\n<p>Once the heap dump is created, we can load it into <a href=\"https:\/\/visualvm.github.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">VisualVM<\/a> or the NetBeans Profiler\u2019s GUI to examine memory usage. In this example, however, we utilize NetBeans\u2019 built-in in-code APIs to analyze heap dumps directly through code. Below is an example of how to load and analyze a heap dump programmatically using the NetBeans API:<\/p>\n<pre class=\"brush:java\">\nimport java.io.File;\nimport java.io.IOException;\nimport org.netbeans.lib.profiler.heap.HeapSummary;\nimport org.netbeans.lib.profiler.heap.Heap;\nimport org.netbeans.lib.profiler.heap.HeapFactory;\n\npublic class ProfilingExample {\n\n    private static Heap heap;\n\n    private static void analyzeHeapDump() throws IOException {\n        heap = HeapFactory.createHeap(new File(\"heapdump.hprof\"));\n\n        HeapSummary summary = heap.getSummary();\n\n        System.out.println(\"Total number of instances: \" + summary.getTotalLiveInstances());\n        System.out.println(\"Memory usage in bytes: \" + summary.getTotalLiveBytes());\n        System.out.println(\"GC Roots: \" + heap.getGCRoots().size());\n        System.out.println(\"Total number of Classes: \" + heap.getAllClasses().size());\n        System.out.println(\"Timestamp: \" + summary.getTime());\n\n    }\n\n    public static void main(String[] args) throws IOException {\n        Library cityLibrary = new Library(1, \"Programming Library\");\n        cityLibrary.addBook(\"Java Programming Essentials\");\n        cityLibrary.addBook(\"Data Structures and Algorithms\");\n        cityLibrary.addSection(\"Technology\");\n        cityLibrary.addSection(\"Literature\");\n\n        Library homeLibrary = new Library(1, \"Philosophical Library\");\n        homeLibrary.addBook(\"Age of Reason\");\n        homeLibrary.addBook(\"The Principles of Nature\");\n        homeLibrary.addSection(\"Philosophy\");\n\n        File f = new File(\"heapdump.hprof\");\n        if (f.exists()) {\n            f.delete();\n        }\n\n        HeapDumpUtility.dumpHeap(\"heapdump.hprof\", true);\n\n        analyzeHeapDump();\n\n    }\n}\n\n<\/pre>\n<p>In the <code>main<\/code> method, two <code>Library<\/code> instances (<code>cityLibrary<\/code> and <code>homeLibrary<\/code>) are created, each with sample data representing books and sections. After initializing these objects, the code calls <code>HeapDumpUtility.dumpHeap()<\/code> to generate a heap dump file, <code>heapdump.hprof<\/code>, which captures the current memory state, including object references and the structure of <code>Library<\/code> instances and related data. This setup simulates a basic memory allocation scenario in which objects are created and stored for later analysis.<\/p>\n<p>Following the heap dump creation, the <code>analyzeHeapDump<\/code> method loads the heap dump file using the NetBeans Profiler API&#8217;s <code>HeapFactory.createHeap()<\/code> method. This method generates a <code>Heap<\/code> instance from the dump file, enabling programmatic analysis of the memory contents. <\/p>\n<p>When the code runs, the output will display summary information about the heap dump, including details like the total number of instances, memory usage in bytes, GC roots, the total number of classes, and the timestamp of the dump. Below is an example output and a breakdown of each line:<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/11\/analyzeheapdump.png\"><img decoding=\"async\" width=\"453\" height=\"102\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/11\/analyzeheapdump.png\" alt=\"output of example using java netbeans profiler programmatically\" class=\"wp-image-128439\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/11\/analyzeheapdump.png 453w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/11\/analyzeheapdump-300x68.png 300w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/a><\/figure>\n<\/div>\n<p>These insights provide a snapshot of the memory footprint of the running application at the time of the dump, offering a straightforward way to assess memory allocation and usage within the <code>Library<\/code> instances. Here is a summary of each output line:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Total instances<\/strong>: 31,679 live objects in memory<\/li>\n<li><strong>Memory usage<\/strong>: 1,836,066 bytes of memory allocated (approximately 1.84 MB).<\/li>\n<li><strong>GC Roots<\/strong>: 1,418 objects reachable by garbage collection<\/li>\n<li><strong>Total classes<\/strong>: 1,526 unique classes loaded in the heap<\/li>\n<li><strong>Timestamp<\/strong>: 1731436123085 (time of heap dump creation)<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">5.2 Analyzing Library Class Instances<\/h3>\n<p>In this section, we analyze the memory usage and number of instances for the <code>Library<\/code> class within the heap dump. The following code retrieves the <code>Library<\/code> class from the heap and calculates its memory consumption:<\/p>\n<pre class=\"brush:java\">\n    public static void librarySummary() {\n        JavaClass libraryClass = heap.getJavaClassByName(\"com.jcg.profilingexample.Library\");\n        if (libraryClass == null) {\n            System.out.println(\"Library class not located\");\n            return;\n        }\n        List&lt;Instance&gt; instances = libraryClass.getInstances();\n        long totalSize = 0;\n        long instancesNumber = libraryClass.getInstancesCount();\n        for (Instance instance : instances) {\n            totalSize += instance.getSize();\n        }\n        System.out.println(\"Number of Library instances: \" + instancesNumber);\n        System.out.println(\"Memory consumed by Library instances: \" + totalSize);\n    }\n<\/pre>\n<p>This block of code starts by looking for the <code>Library<\/code> class in the heap using <code>heap.getJavaClassByName(\"com.jcg.profilingexample.Library\")<\/code>. If the class is not found, it prints a message and exits the method. If the class is found, it retrieves all instances of the <code>Library<\/code> class using <code>libraryClass.getInstances()<\/code> and counts how many instances of the class exist in the heap with <code>libraryClass.getInstancesCount()<\/code>.<\/p>\n<p>Next, it calculates the total memory used by all instances of the <code>Library<\/code> class by summing the size of each instance. This is done by iterating over the list of instances and adding up the size of each one using <code>instance.getSize()<\/code>.<\/p>\n<p>Example output:<\/p>\n<pre class=\"brush:plain\">\nNumber of Library instances: 2\nMemory consumed by Library instances: 88\n<\/pre>\n<h4 class=\"wp-block-heading\">Explanation of Output:<\/h4>\n<ul class=\"wp-block-list\">\n<li><strong>Number of Library instances: 2<\/strong> &#8211; This output indicates that there are a total of 2 instances of the <code>Library<\/code> class in memory. The <code>getInstancesCount()<\/code> method counts how many <code>Library<\/code> objects are present within the heap dump.<\/li>\n<li><strong>Memory consumed by Library instances: 88<\/strong> &#8211; This shows the total memory usage (in bytes) by all <code>Library<\/code> instances in the heap. The <code>getSize()<\/code> method is used to sum up the memory taken up by each individual <code>Library<\/code> object, giving the total memory usage.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\">6. Conclusion<\/h2>\n<p>In this article, we explored how to use the NetBeans Profiler API to capture and analyze heap dumps in a Java application. We demonstrated how to create and analyze a heap dump to inspect the memory usage and number of instances of a specific class. By using the provided code, we were able to track the total number of Class instances and their memory consumption, providing valuable insights into the memory behaviour of our application.<\/p>\n<h2 class=\"wp-block-heading\">7. Download the Source Code<\/h2>\n<p>This article covered how to use the Java NetBeans profiler programmatically.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2024\/11\/ProfilingExample.zip\"><strong>java netbeans use profiler programmatically<\/strong><\/a>\n<\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article explores how to use the NetBeans Profiler API to collect heap dumps, analyze memory usage, and inspect specific class instances programmatically within a Java application. We will explore using the NetBeans Profiler API to analyze performance metrics in Java applications programmatically. Rather than relying on VisualVM or GUI-based tools, programmatic profiling provides a &hellip;<\/p>\n","protected":false},"author":128888,"featured_media":192,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[3181,3182,187,3183],"class_list":["post-127348","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-heap-dump-analysis","tag-java-profiling","tag-netbeans","tag-netbeans-profiler"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using the NetBeans Profiler Programmatically in Java - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Learn how to use the Java NetBeans profiler programmatically for performance monitoring, CPU, and memory profiling.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using the NetBeans Profiler Programmatically in Java - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the Java NetBeans profiler programmatically for performance monitoring, CPU, and memory profiling.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/web.facebook.com\/omos.aziegbe\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-15T09:11:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/netbeans-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Omozegie Aziegbe\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/OAziegbe\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Omozegie Aziegbe\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html\"},\"author\":{\"name\":\"Omozegie Aziegbe\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7d3eac6e45542536e961129ae0fb453e\"},\"headline\":\"Using the NetBeans Profiler Programmatically in Java\",\"datePublished\":\"2024-11-15T09:11:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html\"},\"wordCount\":931,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/netbeans-logo.jpg\",\"keywords\":[\"Heap Dump Analysis\",\"Java Profiling\",\"Netbeans\",\"NetBeans Profiler\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html\",\"name\":\"Using the NetBeans Profiler Programmatically in Java - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/netbeans-logo.jpg\",\"datePublished\":\"2024-11-15T09:11:00+00:00\",\"description\":\"Learn how to use the Java NetBeans profiler programmatically for performance monitoring, CPU, and memory profiling.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/netbeans-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/netbeans-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/using-the-netbeans-profiler-programmatically-in-java.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Using the NetBeans Profiler Programmatically in Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/7d3eac6e45542536e961129ae0fb453e\",\"name\":\"Omozegie Aziegbe\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-jcg_profile_pic-96x96.jpg\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-jcg_profile_pic-96x96.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2023\\\/12\\\/cropped-jcg_profile_pic-96x96.jpg\",\"caption\":\"Omozegie Aziegbe\"},\"description\":\"Omos Aziegbe is a technical writer and web\\\/application developer with a BSc in Computer Science and Software Engineering from the University of Bedfordshire. Specializing in Java enterprise applications with the Jakarta EE framework, Omos also works with HTML5, CSS, and JavaScript for web development. As a freelance web developer, Omos combines technical expertise with research and writing on topics such as software engineering, programming, web application development, computer science, and technology.\",\"sameAs\":[\"https:\\\/\\\/web.facebook.com\\\/omos.aziegbe\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/omosaziegbe\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/OAziegbe\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/omozegie-aziegbe\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using the NetBeans Profiler Programmatically in Java - Java Code Geeks","description":"Learn how to use the Java NetBeans profiler programmatically for performance monitoring, CPU, and memory profiling.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html","og_locale":"en_US","og_type":"article","og_title":"Using the NetBeans Profiler Programmatically in Java - Java Code Geeks","og_description":"Learn how to use the Java NetBeans profiler programmatically for performance monitoring, CPU, and memory profiling.","og_url":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_author":"https:\/\/web.facebook.com\/omos.aziegbe","article_published_time":"2024-11-15T09:11:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/netbeans-logo.jpg","type":"image\/jpeg"}],"author":"Omozegie Aziegbe","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/OAziegbe","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Omozegie Aziegbe","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html"},"author":{"name":"Omozegie Aziegbe","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7d3eac6e45542536e961129ae0fb453e"},"headline":"Using the NetBeans Profiler Programmatically in Java","datePublished":"2024-11-15T09:11:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html"},"wordCount":931,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/netbeans-logo.jpg","keywords":["Heap Dump Analysis","Java Profiling","Netbeans","NetBeans Profiler"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html","url":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html","name":"Using the NetBeans Profiler Programmatically in Java - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/netbeans-logo.jpg","datePublished":"2024-11-15T09:11:00+00:00","description":"Learn how to use the Java NetBeans profiler programmatically for performance monitoring, CPU, and memory profiling.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/netbeans-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/netbeans-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/using-the-netbeans-profiler-programmatically-in-java.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Using the NetBeans Profiler Programmatically in Java"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/7d3eac6e45542536e961129ae0fb453e","name":"Omozegie Aziegbe","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/cropped-jcg_profile_pic-96x96.jpg","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/cropped-jcg_profile_pic-96x96.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2023\/12\/cropped-jcg_profile_pic-96x96.jpg","caption":"Omozegie Aziegbe"},"description":"Omos Aziegbe is a technical writer and web\/application developer with a BSc in Computer Science and Software Engineering from the University of Bedfordshire. Specializing in Java enterprise applications with the Jakarta EE framework, Omos also works with HTML5, CSS, and JavaScript for web development. As a freelance web developer, Omos combines technical expertise with research and writing on topics such as software engineering, programming, web application development, computer science, and technology.","sameAs":["https:\/\/web.facebook.com\/omos.aziegbe","https:\/\/www.linkedin.com\/in\/omosaziegbe\/","https:\/\/x.com\/https:\/\/twitter.com\/OAziegbe"],"url":"https:\/\/www.javacodegeeks.com\/author\/omozegie-aziegbe"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/127348","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/128888"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=127348"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/127348\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/192"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=127348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=127348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=127348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}