Generate New Data Record (Java)

Hi,

I designed a component that collects some information from passed records, then enter into a complex algorithm that eventually generates new data records. One issue with this, is that you have to collect new nodes during the whole process, then release them at the component onProcess level (see below, although I assume that everyone knows).

The main issue with this process is when many thousands of nodes are to be collected, you rapidly get a "Java Heap Space" error message.

public Component.State onProcess(Context context, DataRecord data) throws Exception {
     if (data.isNewData()) {

          ...

          data.setRoot(node);

          data.routeTo(Route.PassPort);

          if (nodeIterator.hasNext()) {

               return Component.State.ReadyForNewData;

          }

          else {

               return Component.State.DoneProcessingData;

          }

     }

     else {

          // algorithm here: create nodes and add to the node collection

          nodeIterator = nodeCollection.iterator();

          if (nodeIterator.hasNext()) {

               return Component.State.ReadyNewData;

          }

          else {

               return Component.State.DoneProcessingData;

          }

     }

}         

So, the question is: is there another way to generate new data records which would not loop on "onProcess" and let me generate and send out nodes (data records) directly from the algorithm?
Hope I'm clear enough,
Cheers,
Pierre