ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Rice" <>
Subject PermGen OutOfMemoryError in custom Iterator task, and ForEach - Suggestions Please
Date Mon, 23 Oct 2006 18:57:48 GMT
I recently created a custom task that is an Iterator.  The goal of the task
is to accept a large date range ( like 3 years ) and split it into smaller
date ranges ( like 1 day at a time ).  I do a lot of work with date ranges.
Examples are running queries or fetching files that expect a time range.

At each iteration, the task sets a couple of properties that represent the
limits of the smaller date range.  At this point, the task acts very much
like <antcall>.  It requires one or more targets.  CallTaget tasks are
dynamically constructed for each target for each iteration.  They are then
executed.   The targets that are called are rather large themselves,
ultimately including about 10 targets or dependencies.

The short is that I am running out of memory.  About 70 iterations in (
representing 70 days of work that has been accomplished ), I get an
OutOfMemoryError.  It looks something like:

    [timer] Timer started.  Tasks started.
Exception in thread "Thread-72" java.lang.OutOfMemoryError: PermGen space
    [timer] Timer interrupted. Tasks completed.

And an example stacktrace:
Exception in thread "Thread-71"
/home/robert/dvl/java/bin/RetsDataCollector.xml:161: The following error
occurred while executing this
line:/home/robert/dvl/java/bin/RetsDataCollector.xml:127: Could not create
type mget due to java.lang.OutOfMemoryError: PermGen space        at
        at net.sf.antcontrib.logic.ForEach.execute(Unknown Source)
        at com.windermere.collector.task.Timer$
Caused by: /home/robert/dvl/java/bin/RetsDataCollector.xml:127: Could not
create type mget due to java.lang.OutOfMemoryError: PermGen space        at
        at        at
        ... 5 more
Caused by: java.lang.OutOfMemoryError: PermGen space

It looks to me like each iteration adds to the memory requirement, until I
run out of memory.  Ideally, at each iteration, the dynamically created
<antcall> tasks would no longer be needed and would be garbage collected.
Is it because these <antcall> tasks are ultimately owned by the containing
iterator task?

I'm looking for suggestions on how to get around this problem.  Can I model
my custom task in a different way internally to avoid this problem?

As an aside, I thought I would see if the ant-contrib <foreach> task had the
same end result.  I chose to do this since it is similar.  It instead loops
across a list, then constructing <antcall> tasks within each loop.  It does
indeed also run out of memory, at about the same point as my custom task.

I can provide code snippets of the custom task if that will help.  I'm
guessing others have come across this problem and may have a solution
without digging into the code.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message