0 Replies Latest reply on Apr 30, 2018 2:46 PM by grimrand

    jdk 8 jvisualvm

    grimrand

      Just a bit of advice/info.

       

      I have created and compiled the following two classes in Java 8.

       

      When I use jvisualvm the instances under memory seem to continually increment, i cant see why this should be the case..

       

      Regards

       

       

       

       

       

      package test;

       

      import java.util.ArrayList;;

       

      public class Application {

       

         ArrayList<Hotel> hotels = new ArrayList<Hotel>();

       

         Application () {

       

            hotels.createHotels();

       

            while (True){

       

              try {

                 System.out.println("sleep");

                 Thread.sleep(30000);

              } catch (InterruptedException ex)

      `````   {

                System.out.println ("Error");

         

              }

        

            }

        

          }  

       

          public static void main (String args[]){

            Application app = new Application();

          }

       

       

          public ArrayList<Hotel> createHotels(){

       

             ArrayList<Hotel> tempHotel = new ArrayList<Hotel>();

       

             for (int i = 0; i < 50; i++){

                Hotel hotel = new Hotel("Test");

                tempHotel.add(hotel);

             }

       

             return tempHotel;

          }

       

          

      }

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

      package test;

       

      public class Hotel {

       

         private String name;

       

         Hotel (String name){

           this.name = name;

         }

       

       

         Hotel (){

         }

       

      }