Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
A "memory trick" in `ngx_http_lua_limit_data_segment` leads to redundant memory allocation #1005
Recently I added
Here is the relevant
This was being repeated for many(
As you can see even though
I tested by commenting out the call to
I also tried to call
Here is a small C program to regenerate the exact same behaviour: https://gist.github.com/ElvinEfendi/071e99d24c2235ec892144d5991b56f6
I believe #872 is related.
@agentzh is not that an expected
Here are the
i read the blog: http://www.elvinefendi.com/2017/03/07/my-experience-with-lua-nginx-openssl-strace-gdb-glibc-and-linux-vm.html,but i don't known why.
Do you try the latest one and I guess it will still appear.
I believe that glibc's malloc (ptmalloc2) do not cause memory leak .
Your OpenResty instance hold large memory because of too many
It looks like we need reduce
Maybe #997 is related
@agentzh How do you think of it
I have not got a chance to try this out with the latest
Yep, it's not a memory leak, but it allocates redundant memory, because of
Here is the problem, the allocated memory is way more(redundant) than what's needed to hold decrypted CA file in the cert store in memory.
I looked into this for a bit when I came across this issue, but apparently it's not easy to share a cert store between different SSL sessions(OpenSSL is not thread safe?). I believe this is the reason why this behaviour is same in Nginx core(
Please refer to http://www.elvinefendi.com/2017/03/07/my-experience-with-lua-nginx-openssl-strace-gdb-glibc-and-linux-vm.html for more details.
#997 will be a great step forward in my opinion. At least it will let us to avoid using
@ElvinEfendi The real problem is that glibc never returns a sufficient part of its withholding memory back to the OS when allocating via
So when glibc uses
Anyway, since glibc's behavior is really buggy or broken here, we've just removed this
Use of the
I don't think glibc allocates "redundant" memory. It just to allocate big chunk of memory, and then carve a block out of it.
Luajit will call mmap() to allocate a block in the address space of