in reply to out of memory problem

what do you want us to do?

if you just want to know why your program can't allocate more memory at 3Gb, one helpful pointer might be your ulimit manpage. Also: 3Gb may be your system's limit for any single process (especially if you're running 32 bit systems).

edit: just to be clear; I've run multi-threaded perl processes at 12+ Gb without any problems on 64-bit linux systems.