Welcome! Log In Create A New Profile

Advanced

Re: nginx module memory problem

chen cw
October 08, 2012 11:02PM
It is suspicious that your problem is caused by ngx_pcalloc().

When you allocated a large size of memory, nginx does not allocate it in
pool, instead, it uses standard malloc() in C, because the size is larger
than the pool size. When a block is allocated by malloc(), it may not be
returned to OS even if it has been freed by free(). Why? GCC memory
management layer can cache the blocks in process for future allocation.

I don't understand why you must copy the input chain of client. In fact, if
you can reap the buffers-chain together, you can directly write each part
into log file separately. Moreover, first create a hole in file, then fill
the log into a hole will get rid of interlace among different log records.

On Fri, Oct 5, 2012 at 12:20 AM, Maxim Dounin <mdounin@mdounin.ru> wrote:

> Hello!
>
> On Thu, Oct 04, 2012 at 02:13:17PM +0900, 김영진 wrote:
>
> > hi, i am web server(nginx) module developer.
> > my nginx modules has a major problem.
> > maybe... this problem is seem to nginx core bug.
> > i hope this is my module problem. Because, i wish the problem to be
> settled
> > soon.
> >
> > *my module function:*
> > large post data logging from specified file(nginx.conf setting :
> > /home1/test_access.log)
> > *problem:*
> > constant use of memory(nginx-1.2.2 , same situation)
> > [image: 본문 이미지 1]
>
> [...]
>
> > rc_post = ngx_http_read_client_request_body(r,
> > ngx_testmodule_post_read_request_body);
> >
> > ngx_testmodule_resheader(r);
> > ...
> > return ngx_http_send_response(r, NGX_HTTP_OK, &ngx_http_text_type, &cv);
> > }
> >
> >
> > i have tested my nginx module. but... i don't know.. difficult problem...
> > i am turning to you for help.
>
> One obvious problem in your code is that you use
> ngx_http_read_client_request_body() incorrectly.
>
> After a call to ngx_http_read_client_request_body() you _must_
> follow the pattern
>
> rc = ngx_http_read_client_request_body(r, ...);
>
> if (rc >= NGX_HTTP_SPECIAL_RESPONSE) {
> return rc;
> }
>
> return NGX_DONE;
>
> See e.g. ngx_http_proxy_module.c for an example. Failing to do so
> will likely result in request hangs/socket leaks.
>
> --
> Maxim Dounin
> http://nginx.com/support.html
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>



--

--

Charles Chen

Software Engineer

Server Platforms Team at Taobao.com
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

nginx module memory problem Attachments

김영진 1131 October 04, 2012 01:14AM

Re: nginx module memory problem

Pass86 572 October 04, 2012 10:32AM

Re: nginx module memory problem

Maxim Dounin 549 October 04, 2012 12:22PM

Re: nginx module memory problem

chen cw 536 October 08, 2012 11:02PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 117
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready