Good morning, people.
I made an application in java that at certain times it executes a query to the database and generates a text file.
The application is working correctly in the schedules that have been programmed, however in the time that it stops, it is consuming a lot of memory (around 1300 MB)
I think this is not normal because some desktops and wev applications that would have to have a higher consumption do not even come close to what this application is consuming.
If someone has an idea of what can be or some correction of the problem, follow the code below.
private static String fileStream = "C:\Users\genesys\Documents\RM\arq.txt";
//private static String fileStream = "C:\Users\Vostro-3300\Desktop\A comparar\arq.txt";
public static void main(String[] args) throws IOException {
boolean fim = false;
while(fim == false){
Calendar calendario = new GregorianCalendar();
Date dt = calendario.getInstance().getTime();
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
String dtF = df.format(dt);
if(dtF.equals("06:00:00")||dtF.equals("06:00:01")||dtF.equals("06:00:02")||dtF.equals("06:00:03")){
try{
// função para envio de email
}catch(Exception ex){
ex.printStackTrace();
}
}
if(dtF.equals("18:00:01") ||dtF.equals("18:00:02")||dtF.equals("18:00:03")||dtF.equals("11:25:00")||dtF.equals("11:25:01")||dtF.equals("11:25:02")){
try{
Conecta c = new Conecta();
ArrayList<Dados> lista = c.listar();
FileWriter arq = new FileWriter(fileStream);
PrintWriter print = new PrintWriter(arq);
print.println("CCODCOLIGADA;CODSECAO;DESCRICAO;NROCENCUSTOCONT;NOME;CODFUNCAO;NOME1;CHAPA;NOME2;DTNASCIMENTO;JORNADA;SALARIO;SEXO;DATAADMISSAO;DATADEMISSAO;STATUS;TIPOCONTRATO;DESCRICAOFUNCAO;GRAUINSTRUCAO;CPF;PISPASEP;RG;CTPS;ESTADOCIVIL;ENDERECO;BAIRRO;CIDADE;ESTADO;CEP;TELEFONE;EMAIL;TIPOADMISSAO");
for(Dados d: lista){
print.println(d.getCodLigada()+";"+d.getCodSecao()+";"+d.getDescricao()+";"+d.getNroCenCustoCont()+";"+d.getNomeCent()+";"+d.getCodFuncao()+";"+d.getNomeFunc()+";"+d.getChapa()+";"+d.getNome()+";"+d.getDtNasc()+";"+d.getJornada()+";"+d.getSalario()+";"+d.getSexo()+";"+d.dtAdmissao+";"+d.getDtDemisao()+";"+d.getStatus()+";"+d.getContratoTipo()+";"+d.getCargoDesc()+";"+d.getGrauInstrucao()+";"+d.getCpf()+";"+d.getPisPasep()+";"+d.getRg()+";"+d.getNmrCtps()+";"+d.getEstadoCivil()+";"+d.getEndreco()+";"+d.getBairro()+";"+d.getCidade()+";"+d.getEstado()+";"+d.getCep()+";"+d.getTelefone()+";"+d.getEmail()+";"+d.getTipoAdmissao());
}
arq.close();
}
catch(Exception e){
try{
// função para envio de email
}catch(Exception ex){
ex.printStackTrace();
}
}
}else{
}
}
}