When increasing php memory limit doesn't help


So, I’m trying to get some data from the application using the getLastVisitsDetails api. And, there are two questions here.

And, it fails with this error on the error.log as
[Thu Dec 03 14:45:50 2015] [warn] [client] mod_fcgid: stderr: PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 97 bytes) in /core/DataTable/Renderer/Csv.php on line 199

A. I know that there’s a faq that details this exact error and suggests that we increase the memory in php.ini. However, as you can see here, it’s set to a huge amount of 4GB. The actual file should be in the Mega bytes at the max. How can I overcome this issue?

B. the filter_limit value is set to an arbitrary 4000. Is there a way to get all records instead of guessing the limit number? If I wanted to get this from the database directly using a query, how do I do that?