You may be out of available chunks of memory.
For example, the program might require 300MB of memory, and the system might show 500MB free, but there isn't a 300MB chunk available, there's two 200MB chunks and a 100MB chunk.
Though I still don't know what would eat up 4GB of memory....