in reply to Out of memory during "large" request

It appears to me that your program has asked for additional memory at line 40 and that the machine doesn't have that much available.

Down in the gloomy bowels of the underlying C, sbrk() increments the program's data space by increment bytes. See setlimit(2) in your man pages.

Caveat: This may not be very helpful in solving your problem; with a bit more information, we may be able to offer some possible workarounds.