使用ini_set时遇到的问题('memory_limit',' - 1')

I would like to know, is there any issues(bad to server) while using ini_set('memory_limit', '-1') on number of occasions?

The reason why I need to know this is, I'm now working in a project where use of join queries is high. We are only fetch required data's to avoid maximum load but in some situation where data exceeds 20000+ record, execution dies & shows 500 (Internal Server Error).

I know Error 500 may be cause of lot other issues, so I have checked it & found the reason was because of PHP execution memory limit exceeding(256M). When I set ini_set('memory_limit', '-1') on my code, query executed correctly.

The above explanation is just a situation/scenario, no need to consider that & Yes, I agree that using ini_set('memory_limit', '-1') is a bad practice. So, my question is clearly to know is there any issue on using ini_set('memory_limit', '-1') multiple times on different sections of a project (like sever issues or so). If yes, what are they?

ini_set will set the configuration option during the script's execution, and will be restored at the script's ending.

so ini_set will only works on the current php process. The next time a request coming, a new php process will read php.ini first to get the memory_limit and then you can use ini_set to set the value to -1.

you can use ini_get to check memory_limit to avoid set memory_limit multiple times, and check the return value of ini_set to ensure success.

using ini_set('memory_limit', '-1') is a bad idea. Try to use pagination to avoid fetch all data at a time.