Not sure of your OS, but on Unix, yes there’s a limit.
I don’t remember which parameter it is, but it is in this list:
$ ulimit -a
time(seconds) unlimited
file(blocks) 2097151
data(kbytes) 131072
stack(kbytes) 98304
memory(kbytes) 98304
coredump(blocks) 2097151
nofiles(descriptors) 2000
I ran into a similiar problem and had to write information out to a file after x number of records to keep the script from core dumping.
Steve