rchinoy
2009-04-02 17:08:48 UTC
Hi all,
I use CFCs a lot, so when I was creating a tool to migrate some database
tables, I built the actual data transfer function as a method of a CFC. The
basic code just reads a block of 1000 records from the old db, does some minor
manipulation of the data, and then inserts the records into the new db a record
at a time inside a cfloop. Lather, rinse, repeat, until all of the 500K+
records have been transferred.
I was surprised to find that this leads to Java out of memory errors around
the 200Kth record (given my current JVM memory settings). Having run across a
similar problem when sending broadcast emails from a CFC method, I simply moved
the code out of the CFC method and into the calling cfm page, and it ran
through all of the records without any problems.
The only explanation I can think of for this behavior is that when the code is
inside a CFC method, the query object used to read the blocks of 1000 records
keeps getting reallocated rather than reused, so when it gets to the point of
trying to store 200 blocks of 1000 records in memory, it runs out of room. If
that's the case, it would seem to be a significant bug that needs to be fixed.
Does anyone know if that's what is really going on?
Thanks,
Russ
I use CFCs a lot, so when I was creating a tool to migrate some database
tables, I built the actual data transfer function as a method of a CFC. The
basic code just reads a block of 1000 records from the old db, does some minor
manipulation of the data, and then inserts the records into the new db a record
at a time inside a cfloop. Lather, rinse, repeat, until all of the 500K+
records have been transferred.
I was surprised to find that this leads to Java out of memory errors around
the 200Kth record (given my current JVM memory settings). Having run across a
similar problem when sending broadcast emails from a CFC method, I simply moved
the code out of the CFC method and into the calling cfm page, and it ran
through all of the records without any problems.
The only explanation I can think of for this behavior is that when the code is
inside a CFC method, the query object used to read the blocks of 1000 records
keeps getting reallocated rather than reused, so when it gets to the point of
trying to store 200 blocks of 1000 records in memory, it runs out of room. If
that's the case, it would seem to be a significant bug that needs to be fixed.
Does anyone know if that's what is really going on?
Thanks,
Russ