public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Sainath Latkar <latkarsainath@gmail.com>
To: libc-maintainers@gnu.org, libc-help@sourceware.org
Subject: Query regarding malloc_trim
Date: Thu, 30 Aug 2018 13:55:00 -0000	[thread overview]
Message-ID: <CAP48-ke12a2g-bVVTas6+X6MD-eh313qBAf4NTumfa1UxCZrwg@mail.gmail.com> (raw)

Hi GLIBC team,
I observed weird behavior with memory utilization of our application. The
issue narrows down to the usage of *std::queue* putting small chunks of
data in the queue and emptying the queue completely after some time.
In the life cycle of our application, a particular queue gets populated
with more than a million records and after around 7 to 10 minutes, we empty
the queue completely. At this point, logically the heap memory held by
these objects should be freed but it doesn’t happen. One more observation
is that if we put enough memory usage load on our system this surplus
memory goes into swap.
So the program is never freeing up the memory. This memory gets freed at
the end of .org applications life cycle. This indeed is not a memory leak,
because if we try to acquire more heap memory, application reuses the
surplus memory and doesn’t allocate more.

As I understood after reading up a bit, as part of optimization, Glibc
allocators cache this memory for later use. Using *malloc_trim* we can
return this heap memory to the system. I tried using *malloc_trim* and it
works as expected
My question is, is there any other way around this optimization, apart from
using malloc trim and *M_TRIM_THRESHOLD*? Also note that we are not using
c++ 11 so using Shriya to fit is out of the picture.


Thanks, Sainath Latkar.

             reply	other threads:[~2018-08-30 13:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 13:55 Sainath Latkar [this message]
2018-08-31 19:01 ` Carlos O'Donell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP48-ke12a2g-bVVTas6+X6MD-eh313qBAf4NTumfa1UxCZrwg@mail.gmail.com \
    --to=latkarsainath@gmail.com \
    --cc=libc-help@sourceware.org \
    --cc=libc-maintainers@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).