It depends on your script. Sorry bit without further information i think it is impossible to help you.
If you have the possibility to costumize php.ini then you could increase memory_limit
;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;
max_execution_time = 30 ; Maximum execution time of each script, in seconds
memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)
But I think its better to analyze the skript, why it is consuming more than 4MB. What does the skript do?