Share the lines of code executed when you make this request. There might be an error in your code.
Also, you can change the memory limit in your php.ini file via the memory_limit
setting. Try doubling your memory to 64M. If this doesn't work you can try doubling it again, but I'd bet the problem is in your code.
ini_set('memory_limit', '64M');