Would that be something like this?

Although it didn't fix the leak, which was the entire point of this
exercise.

Maybe because driver::finalize () is not getting called so the call to
mdswitches.release () doesn't really happen, which was the reason
I went with std::vector in the first place because it takes care of itself.


On Wed, 6 Dec 2023 at 14:39, Jakub Jelinek <ja...@redhat.com> wrote:

> On Wed, Dec 06, 2023 at 02:29:25PM +0000, Costas Argyris wrote:
> > Attached a new patch with these changes.
> >
> > On Mon, 4 Dec 2023 at 12:15, Jonathan Wakely <jwak...@redhat.com> wrote:
> >
> > > On Sat, 2 Dec 2023 at 21:24, Costas Argyris wrote:
> > > >
> > > > Use std::vector instead of malloc'd pointer
> > > > to get automatic freeing of memory.
> > >
> > > You can't include <vector> there. Instead you need to define
> > > INCLUDE_VECTOR before "system.h"
> > >
> > > Shouldn't you be using resize, not reserve? Otherwise mdswitches[i] is
> > > undefined.
>
> Any reason not to use vec.h instead?
> I especially don't like the fact that with a global
> std::vector<whatever> var;
> it means runtime __cxa_atexit for the var the destruction, which it really
> doesn't need on exit.
>
> We really don't need to free the memory at exit time, that is just wasted
> cycles, all we need is that it is freed before the pointer or vector is
> cleared.
>
>         Jakub
>
>

Attachment: 0001-driver-Fix-memory-leak.patch
Description: Binary data

Reply via email to