Help me with the manipulation of statistics using the genesys SDK =)

Hello friends,
I am new to genesys, by using the Genesys SDK I am trying to make an application in java where I query a database where I get 2000 records, where each record has the necessary properties to query the statserver But I observe in the processes of java, the memory increases with the passage of time. I have reviewed the source code and closed some variables that I have declared in my program, however it follows this elevation of memory.

Please can you guide me where I am failing
Below I show an extract from the code lines of my program.

  1. What I do in this method is to scroll through all fields already loaded and then set all the properties for sending to the statserver

     public void loadRetrieveStatistict(StatServerProtocol statServerConexion) {
     try {
         for (CampanaBean campana : index_campana.values()) {
             if (campana.getId() > 0) {
                 listCampos = campana.getCampos();
                 if (listCampos != null || !listCampos.isEmpty()) {
                     for (CampoBean campo : listCampos) {
    
                         if (campo.getNombre_objeto_genesys() == null) {
                             campo.setNombre_objeto_genesys("");
                         }
    
                         if (campo.getNombre_objeto_genesys().trim().length() > 0) {
                             index_campos.put(campo.getId(), campo);
                             Notification notificacion = Notification.create();
                             notificacion.setMode(NotificationMode.Immediate);
                             requestOpenStatistic = RequestOpenStatistic.create();
                             StatisticObject object = StatisticObject.create();
                             System.out.print(" id:" + campo.getId() + " , campana : " + campo.getCampana().getId() + ", " + campo.getNombre_objeto_genesys() + " ");
                             object.setObjectId(campo.getNombre_objeto_genesys().trim());
                             object.setObjectType(Util.getStatistic(campo.getType_object()));
                             System.out.print(", " + campo.getType_object() + "");
                             object.setTenantName("Resources");
                             object.setTenantPassword("");
                             StatisticMetric metric = StatisticMetric.create();
                             metric.setStatisticType(campo.getNombre_metrica().trim());
                             System.out.print("," + campo.getNombre() + ", ");
                             metric.setFilter(campo.getName_filter());
                             requestOpenStatistic.setStatisticObject(object);
                             requestOpenStatistic.setStatisticMetric(metric);
                             requestOpenStatistic.setNotification(notificacion);
                             requestOpenStatistic.setReferenceId(campo.getId());
                             System.out.println("enviando.....");
                             statServerConexion.send(requestOpenStatistic);
                         }
    
                     }
                 }
    
             }
         }
     } catch (Exception ex) {
         ex.printStackTrace();
     }
    

    }

  2. In the following fragment, I start the previous method and the class in charge of reading the events of the changes of values of the metrics returned by the genesys

    @Override
    public void run() {
    try {
    statServerProtocol.setMessageHandler(this);
    statServerProtocol.open();
    this.loadRetrieveStatistict(statServerProtocol);
    while (true) {
    TimeUnit.SECONDS.sleep(1);
    }
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    }

  3. In the following is a method that is implemented from MessageHandler to capture the statistical values
    @Override
    public void onMessage(Message msg) {
    EventInfo event = (EventInfo) msg;

     try {
         System.out.println("ID: " + event.getReferenceId() + " , value1 :" + event.getIntValue() + ", value2:" + event.getStringValue());
    
       
     } catch (Exception ex) {
         ex.printStackTrace();
     }
    

    }

Is there any way to optimize this process with regards to sending to statserver.
I could help where I am failing, I will be grateful for the support =)

Memory leak is mostly from map data.
Check out “index_campos” map.
And also checkout java heap dump.
Heap dump is made when OOM occurred.
But You can make heap dump with command before OOM.
Google it~