使用 AJAX 会增加 PHP 的内存使用吗?

发布于 2024-08-19 18:40:05 字数 817 浏览 5 评论 0原文

我认为这个问题的答案是否定的,但我没有更多线索来解决我试图找出的问题。

我最初有一个脚本通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笑咖 2024-08-26 18:40:05

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?

花伊自在美 2024-08-26 18:40:05

在 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.

素罗衫 2024-08-26 18:40:05

不会。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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文