LuckyPants
  • Home
  • Poems
  • Python
    • Python Interview Prep Notes for Students >
      • Merge Intervals Leetcode
      • Merge k Sorted Lists
    • Python Setup >
      • Pep 8 style guide
    • Lecture 1 - Basics
    • Lecture 2 - Loops, Lists >
      • Homework 2 Program 1 Step By Step
      • Homweork 2 Shuffle String Program
    • Lecture 3 - structures, packing, string functions >
      • Homework
      • Additional Exercises - you do not need to submit these
    • Lecture 4 - Dictionaries, Functions, Modules
    • Lecture 5 - functions, variable scope, modules >
      • Previous Exams
    • Lecture 6 - CLI, Files, Regex, pickle, shelve
    • Lecture 7 - capturing web content >
      • Processing XML data
    • Midterm Prep >
      • Programming assignment prep
    • Lecture 8 - Exceptions, Classes, Inheritance >
      • Exceptions Recording
      • Multiple Except Clauses Recording
      • Eating an Exception Recording
      • finally and else clause recordings
      • Exception Stack Trace Recording
      • exit() and CTRL+C
      • Class Variables Recording
      • Static Methods and Class Methods Recording
      • Inheritance Recordings
    • Section 9 - db, flask, pip >
      • Accessing Databases
      • HTTP Server
      • Web Applications
      • Finding and installing additional Libraries with pip
      • Web Services with Flask
      • Calling Web Services from Python
      • Placing your application on the web
    • Section 10 - flask, grpc, venv, docker >
      • Flask based Web Applications
      • gRPC
      • Packaging, Dependencies and Virtual Environments
      • Dockerized Python Application
    • Section 11 - Django, GUI >
      • Cross Site Scripting XSS and markupsafe
      • Django >
        • Cross Site Request Forgery CSRF
      • tkinter - frame and button
      • Toplevel
      • Frame
      • Mouse and Keyboard Events
      • Canvas
      • Menu
      • Radiobuttons and Checkboxes
      • Entry
      • ImageMagic
    • Lecture 12 - WebSockets, System Monitoring, PyGame >
      • Web Sockets
      • PyGame Platformer
    • Lecture 13 - Data Structure and Algorithms >
      • Arrays and Strings
      • Dictionaries
      • Linked Lists
      • Trees
      • Stack and Queue
      • Sets
      • Merge Sort
      • Coverage Reports
    • Lecture 14 - Subprocesses, Threads, Multiprocessing >
      • Graphs
      • Singleton Design Pattern
      • Subprocesses and Multithreading
      • Jupiter Notebooks
      • Pandas Operations
    • Extra >
      • Raspberry Pi
      • Raspberry PI home security
      • OpenCV and template matching
      • Compare SQLite DB's in Python
      • Natural Language Processing and nltk
      • Hackathon Projects
  • SaaS
    • Java Interview Prep Notes for Students
    • Setup >
      • SaaS and Cloud Computing
      • Eclipse set up
      • Building web application in Eclipse using Tomcat
    • Section2 >
      • Maven Intro
      • Set up a simple web app and deploy on Heroku
      • Add Jersey Dependencies
      • Dissecting our first REST service
    • Section3 >
      • Jackson intro
      • @POST, @PUT, @DELETE
      • Your Project
    • Section4 >
      • Rules of Injection
      • Root Resource, Subresource, Subresource Locator
      • @CONTEXT
    • Section 5 >
      • Heroku, Java, Jersey and Postgres
      • Music Store with Postgres
      • Working with Files
      • Storing files in Postgres
      • Homework
    • Section 6 >
      • Books Store with Mongo
      • Google APIs
      • Twitter APIs
      • Properties for a web application
      • Homework
    • Section 7 >
      • Jersey Client Famework
      • Java Jersey SalesForce and OAuth
      • Servlets and JSP
      • Data access examples
    • Section 8 >
      • MVC - Model View Controller
      • JSTL Core tags
      • Scopes
      • Building Services to work with forms
    • Section 9 >
      • Calling REST services with JQuery
      • Angular.js
    • Section 10 >
      • consuming SOAP services
      • Web Sockets
      • Websockets, continued
    • Section 11 - Software Development Methodologies, Testing, Performance and Security >
      • Software Development Methodologies
      • Testing, Performance and Security
    • Your Project
    • Previous Projects
    • Course Project Submission
    • SaaS Projects
    • Install Tomcat on Mac

jconsole

10/4/2020

0 Comments

 
​Some good resources/tutorials:
https://www.youtube.com/watch?v=iixQAYnBnJw
​https://www.toptal.com/java/hunting-memory-leaks-in-java

I'm not going to talk too much about what it is, it's all here:                                               
​ ​https://docs.oracle.com/javase/1.5.0/docs/guide/management/jconsole.html

This post is primarily to learn how to use it.

Start off with a Java program that runs indefinitely and creates objects.
import java.time.Instant;

class Jmap{
                String name;
                
                public Jmap(String name) {
                        this.name = name;
                        System.out.println("New Object with name " + name + " created");
                }
                
                @Override
                public void finalize() {
                        System.out.println("Obkect with name " + name + " destroyed");
                }
                
                @Override
                public String toString() {
                        return this.name;
                }
        }


public class JMapTutorial {
        

        public static void main(String[] args) {
                Jmap j;
                while(true) {
                        try {
                                Thread.sleep(10000);
                                j = new Jmap(Instant.now().toString());
                        } catch (InterruptedException e) {
                                
                                //e.printStackTrace();
                        }
                }
        }

}
​Find the Java process running using command:

ps -ef | grep java

look for what you want to monitor, in this case I had (the PID I need is in red):

501 90817   555   0 12:31PM ??         0:00.33 /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 -classpath /Users/gulanurmatova/eclipse-workspace/bin JMapTutorial


Run the JCONSOLE:

$ jconsole 90817

Output of the program  run below and the screenshot of the Jconsole - everything makes sense so far - create, create, create, bunch of clean-ups and then again create, create, create. Let's see what happens next... 

0 Comments



Leave a Reply.

    This is a collection of interview prep programs, online resources that were used in my Java classes. The Java classes were taught years ago, hence the material is likely outdated, I will make an effort to go through it and update as time permits

    Categories

    All
    Algorithms
    Basics
    Leetcode

  • Home
  • Poems
  • Python
    • Python Interview Prep Notes for Students >
      • Merge Intervals Leetcode
      • Merge k Sorted Lists
    • Python Setup >
      • Pep 8 style guide
    • Lecture 1 - Basics
    • Lecture 2 - Loops, Lists >
      • Homework 2 Program 1 Step By Step
      • Homweork 2 Shuffle String Program
    • Lecture 3 - structures, packing, string functions >
      • Homework
      • Additional Exercises - you do not need to submit these
    • Lecture 4 - Dictionaries, Functions, Modules
    • Lecture 5 - functions, variable scope, modules >
      • Previous Exams
    • Lecture 6 - CLI, Files, Regex, pickle, shelve
    • Lecture 7 - capturing web content >
      • Processing XML data
    • Midterm Prep >
      • Programming assignment prep
    • Lecture 8 - Exceptions, Classes, Inheritance >
      • Exceptions Recording
      • Multiple Except Clauses Recording
      • Eating an Exception Recording
      • finally and else clause recordings
      • Exception Stack Trace Recording
      • exit() and CTRL+C
      • Class Variables Recording
      • Static Methods and Class Methods Recording
      • Inheritance Recordings
    • Section 9 - db, flask, pip >
      • Accessing Databases
      • HTTP Server
      • Web Applications
      • Finding and installing additional Libraries with pip
      • Web Services with Flask
      • Calling Web Services from Python
      • Placing your application on the web
    • Section 10 - flask, grpc, venv, docker >
      • Flask based Web Applications
      • gRPC
      • Packaging, Dependencies and Virtual Environments
      • Dockerized Python Application
    • Section 11 - Django, GUI >
      • Cross Site Scripting XSS and markupsafe
      • Django >
        • Cross Site Request Forgery CSRF
      • tkinter - frame and button
      • Toplevel
      • Frame
      • Mouse and Keyboard Events
      • Canvas
      • Menu
      • Radiobuttons and Checkboxes
      • Entry
      • ImageMagic
    • Lecture 12 - WebSockets, System Monitoring, PyGame >
      • Web Sockets
      • PyGame Platformer
    • Lecture 13 - Data Structure and Algorithms >
      • Arrays and Strings
      • Dictionaries
      • Linked Lists
      • Trees
      • Stack and Queue
      • Sets
      • Merge Sort
      • Coverage Reports
    • Lecture 14 - Subprocesses, Threads, Multiprocessing >
      • Graphs
      • Singleton Design Pattern
      • Subprocesses and Multithreading
      • Jupiter Notebooks
      • Pandas Operations
    • Extra >
      • Raspberry Pi
      • Raspberry PI home security
      • OpenCV and template matching
      • Compare SQLite DB's in Python
      • Natural Language Processing and nltk
      • Hackathon Projects
  • SaaS
    • Java Interview Prep Notes for Students
    • Setup >
      • SaaS and Cloud Computing
      • Eclipse set up
      • Building web application in Eclipse using Tomcat
    • Section2 >
      • Maven Intro
      • Set up a simple web app and deploy on Heroku
      • Add Jersey Dependencies
      • Dissecting our first REST service
    • Section3 >
      • Jackson intro
      • @POST, @PUT, @DELETE
      • Your Project
    • Section4 >
      • Rules of Injection
      • Root Resource, Subresource, Subresource Locator
      • @CONTEXT
    • Section 5 >
      • Heroku, Java, Jersey and Postgres
      • Music Store with Postgres
      • Working with Files
      • Storing files in Postgres
      • Homework
    • Section 6 >
      • Books Store with Mongo
      • Google APIs
      • Twitter APIs
      • Properties for a web application
      • Homework
    • Section 7 >
      • Jersey Client Famework
      • Java Jersey SalesForce and OAuth
      • Servlets and JSP
      • Data access examples
    • Section 8 >
      • MVC - Model View Controller
      • JSTL Core tags
      • Scopes
      • Building Services to work with forms
    • Section 9 >
      • Calling REST services with JQuery
      • Angular.js
    • Section 10 >
      • consuming SOAP services
      • Web Sockets
      • Websockets, continued
    • Section 11 - Software Development Methodologies, Testing, Performance and Security >
      • Software Development Methodologies
      • Testing, Performance and Security
    • Your Project
    • Previous Projects
    • Course Project Submission
    • SaaS Projects
    • Install Tomcat on Mac