Re: [RFD PATCH 0/3] Free all the memory!
- From
- Eric Wong <e@80x24.org>
- Date
- May 18, 2016, 07:23 UTC
- Message-ID
- <20160518072329.GA1723@dcvr.yhbt.net>
- In-Reply-To
- <CAGZ79kaJoAxqtsTuErQSgJiVeD_vdZ1MQXKr-LTtyro-FbscTQ@mail.gmail.com>
Stefan Beller <sbeller@google.com> wrote:
Show 7 quoted lines
> Eric Wong writes: > > I haven't checked for git, but I suspect we get speedups by not > > calling free(). I've never needed to profile git, but free() at > > exit has been a measurable bottleneck in other projects I've > > worked on. Often, free() was more expensive than *alloc(). > > Thanks for reiterating that original response I got back then :)
Heh, I suspected I missed some of the original discussion.
Show 9 quoted lines
> > #ifdef FREE_ALL_MEMORY
> > static inline void optional_free(void *ptr) {}
> > #else
> > # define FREE_ALL_MEMORY (0)
> > # define optional_free(ptr) free(ptr)
> > #endif
>
> Shouldn't that be "#ifndef" instead? I really like the
> "optional_free", I'll keep it in mind!Yes, I got my conditionals backwards. That's what I get for being awake way past my bedtime :x
We may also want to find a way to annotate *alloc calls as "lifetime" so they can pair with optional_free. Maybe sparse can help with that?