Help, with java.lang.OutOfMemoryError error

0

Good morning, I am developing a program to help me count how long the basic orderings take and thus make a complexity analysis, but I run into this error of "java.land.OutOfMemoryError: GC overhead limit exceeded", I do not know if it has to do with my pc or something else.

I really appreciate the help and response.

This is the main code in which I run the orderings, the sorting algorithms are the same but developed in a separate class and called with the sort () method.

public class main {

static ArrayList <Integer> listaNumeros = new ArrayList<>();


public static void leerDatos(){


    File archivo = new File("10_7");
    try {
        FileReader fr = new FileReader(archivo);
        BufferedReader br = new BufferedReader(fr);

        String numeros ;
        while((numeros = br.readLine())!=null) { 

            String []lista = numeros.split(",");
            for(int k = 0;  k < lista.length; k++){
                int datos = Integer.parseInt(lista[k]);
                listaNumeros.add(datos); 


            }
        }

    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

public static void main(String[] args) {
    /*
        Sort1.  Ordenamiento Burbuja.
        Sort2.  Ordenamiento por Selección.
        Sort3.  Ordenamiento por Inserción.
        Sort4.  Shellsort.
        Sort5.  Quicksort.
        Sort6.  Treesort.
        Sort7.  Heapsort.
    */
    int key=1; /////////////////////////////////////CAMBIAR EL NUMERO SEGUN EL SORT QUE SE VA A HACER
    double tiempo; //Se medira el tiempo
    leerDatos(); //Lee el archivo para 


    BubbleSort Sort1 = new BubbleSort();
    SelectionSort Sort2 = new SelectionSort();
    Insercion Sort3 = new Insercion();
    Shell Sort4 = new Shell();
    QuickSort Sort5 = new QuickSort();
    Treesort Sort6 = new Treesort();
    HeapSort Sort7 = new HeapSort();
    long start = System.nanoTime();//inicia a contabilizar el tiempo
    long end ;// fin de contabilizar metodo

        Sort1.Sort(listaNumeros);
        end = System.nanoTime();// fin de contabilizar metodo
        tiempo= (double)(end-start)*1.0e-9;
        System.out.println("\nTiempo total "+ tiempo);  

        start = System.nanoTime();
        Sort2.Sort(listaNumeros);
        end = System.nanoTime();// fin de contabilizar metodo
        tiempo= (double)(end-start)*1.0e-9;
        System.out.println("\nTiempo total "+ tiempo);  

        start = System.nanoTime();
        Sort3.sort(listaNumeros);
        end = System.nanoTime();// fin de contabilizar metodo
        tiempo= (double)(end-start)*1.0e-9;
        System.out.println("\nTiempo total "+ tiempo);  

        start = System.nanoTime();
        Sort4.shell_Method(listaNumeros);
        end = System.nanoTime();// fin de contabilizar metodo
        tiempo= (double)(end-start)*1.0e-9;
        System.out.println("\nTiempo total "+ tiempo);  

        start = System.nanoTime();
        Sort5.quickSort(listaNumeros, 0, listaNumeros.size()-1);
        end = System.nanoTime();// fin de contabilizar metodo
        tiempo= (double)(end-start)*1.0e-9;
        System.out.println("\nTiempo total "+ tiempo);  

        start = System.nanoTime();
        Sort6.agregarListas(listaNumeros);
        end = System.nanoTime();// fin de contabilizar metodo
        tiempo= (double)(end-start)*1.0e-9;
        System.out.println("\nTiempo total "+ tiempo);  

        start = System.nanoTime();
        Sort7.ordenar(listaNumeros);
        end = System.nanoTime();// fin de contabilizar metodo


    //for (int i = 0; i < listaNumeros.size(); i++) System.out.println(listaNumeros.get(i));

    tiempo= (double)(end-start)*1.0e-9;
    System.out.println("\nTiempo total "+ tiempo);  
}

}

Thank you very much for the attention

    
asked by jjimenezn 31.08.2017 в 03:46
source

0 answers