使用 AJAX 会增加 PHP 的内存使用吗?
我认为这个问题的答案是否定的,但我没有更多线索来解决我试图找出的问题。
我最初有一个脚本通过 SQLCMD 执行一些数据库查询。我现在决定通过 AJAX 启动此脚本并等待响应。但我得到了一个致命错误:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 445 bytes) in C:\process_txt.php on line 109
我在脚本中更改的唯一新内容是这个 ajax 请求,老实说,没有其他任何内容,这就是我问这个问题的原因。
我使用 JQuery AJAX 请求,但我不认为我正在使用轮询。这是我使用的 AJAX GET 请求示例:
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);
});
}
感谢任何可以尝试阐明这个问题而不是我遇到的问题,只是这个问题的人! :)
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! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
AJAX 与常规调用对服务器没有任何区别。就 PHP 而言,什么都不会改变——请求只是一个请求,无论它是如何从客户端发起的。
我会在其他地方寻找内存泄漏的根源 - 如果指定了某些参数,处理器可能会进入无限循环?
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 使用更少的内存。
In the context of PHP memory: Using AJAX is the same as not using AJAX, but as a result of using AJAX you can output less data back to the user in the HTTP response, which makes PHP to use less memory.
不会。JS 的请求和浏览器地址栏的请求是一样的。
哦等等,JSON/XML 的字节数比 HTML 少!所以这样更好。
查看您的 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.