简体   繁体   中英

Does the use of AJAX increase memory usage of PHP?

I think the answer to this question is no but I do not have anymore leads of the problem I am trying to figure out.

I initially had a single script that did some database queries via SQLCMD. I have now decided to initiate this script via AJAX and wait for the response. But I get a fatal error of:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 445 bytes) in C:\process_txt.php on line 109

The only new thing that I have changed in my script is this ajax request and nothing else to be honest which is why I have asked this question.

I use JQuery AJAX request and I don't think I am using polling. Here is an example AJAX GET request that I make use of:

function process_txt(checkbox){

            waiting = 1;

            var folder_path = $('#folder_path').val();

            var file_name = $('#'+ checkbox + '_val').val();

            $.get("process_txt.php", { path:  folder_path, file: file_name},

            function(data){

                           alert(data);             

            });

}

Thanks to anyone that can try to shed some light on this matter and not the problem I am having, just this question! :)

AJAX vs a regular call will make no difference to the server. As far as PHP is concerned, nothing will have changed - the request is just a request, regardless of how it was initiated from the client.

I'd look for the source of your memory leak elsewhere - perhaps the processor can get in an infinite loop if certain parameters are specified?

在PHP内存的上下文中:使用AJAX与不使用AJAX相同,但是由于使用AJAX,您可以在HTTP响应中将更少的数据输出回用户,这使得PHP使用更少的内存。

No. The requests from JS and browser's address bar are the same. Oh wait, JSON/XML is less bytes than HTML! So it's better.

Look at your PHP code - maybe there's some bugs in database queries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM