Help: OutOfMemory error


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Help: OutOfMemory error

  1. #1
    Keven Guest

    Help: OutOfMemory error


    Hi:

    My code is to parse a large text format data file, create data object for
    each record and save the object data in file. Within the loop of parsing
    ( read in a line a time ), I create a new object, fill it with data and then
    output to file.

    Since the data file is huge, after created 10711 objects, the program run
    out of memory. I assume the Garbage Collector can release the memory resource,
    but it seems not in time.

    anybody can tell me how to mnanager the memory usage in such a situation?


    Keven
    yqian0@hotmail.com


  2. #2
    Paul Clapham Guest

    Re: Help: OutOfMemory error

    It sounds as if you are keeping a reference to each of your objects as you
    create them. Otherwise, the garbage collector should be able to reuse their
    memory. Are you storing them in an array or something like that? Check
    your program. If you don't need the object after you output it to the file,
    make sure you don't have any variables that refer to it.

    Keven <yqian0@hotmail.com> wrote in message news:395baeb2$1@news.devx.com...
    >
    > Hi:
    >
    > My code is to parse a large text format data file, create data object for
    > each record and save the object data in file. Within the loop of parsing
    > ( read in a line a time ), I create a new object, fill it with data and

    then
    > output to file.
    >
    > Since the data file is huge, after created 10711 objects, the program run
    > out of memory. I assume the Garbage Collector can release the memory

    resource,
    > but it seems not in time.
    >
    > anybody can tell me how to mnanager the memory usage in such a situation?
    >
    >
    > Keven
    > yqian0@hotmail.com
    >




  3. #3
    Gabriele Ambrosino Guest

    Re: Help: OutOfMemory error


    If you are not keeping a reference to each of your objects, you can try to
    explicitly run the java garbage collector by invoking the method System.gc().
    You can modify your program to invoke the gc when a specific threshold has
    been reached. Please note that the performance of your program may degrade
    somewhat as it waits for the method call to the gc to return.


    "Paul Clapham" <pclapham@core-mark.com> wrote:
    >It sounds as if you are keeping a reference to each of your objects as you
    >create them. Otherwise, the garbage collector should be able to reuse their
    >memory. Are you storing them in an array or something like that? Check
    >your program. If you don't need the object after you output it to the file,
    >make sure you don't have any variables that refer to it.
    >
    >Keven <yqian0@hotmail.com> wrote in message news:395baeb2$1@news.devx.com...
    >>
    >> Hi:
    >>
    >> My code is to parse a large text format data file, create data object

    for
    >> each record and save the object data in file. Within the loop of parsing
    >> ( read in a line a time ), I create a new object, fill it with data and

    >then
    >> output to file.
    >>
    >> Since the data file is huge, after created 10711 objects, the program

    run
    >> out of memory. I assume the Garbage Collector can release the memory

    >resource,
    >> but it seems not in time.
    >>
    >> anybody can tell me how to mnanager the memory usage in such a situation?
    >>
    >>
    >> Keven
    >> yqian0@hotmail.com
    >>

    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center