[m-rev.] for review: work around bug in reusing memory zones
Peter Wang
wangp at students.csse.unimelb.edu.au
Tue Dec 5 14:36:23 AEDT 2006
On 2006-12-04, Zoltan Somogyi <zs at csse.unimelb.edu.au> wrote:
> On 01-Dec-2006, Peter Wang <wangp at students.csse.unimelb.edu.au> wrote:
> > runtime/mercury_memory_zones.c:
> > Add MR_dealloc_zone_memory() functions to free memory zones.
> >
> > Work around the problem above by freeing memory zones when they
> > are not needed instead of putting them on the free list.
> >
> > I didn't test all the variants of MR_dealloc_zone_memory.
>
> The idea is fine. I'd rather you you chose between the old and new code
> not with "if (1)", but with #ifdef/#else/#endif.
Ok.
> > @@ -484,6 +539,9 @@ MR_construct_zone(const char *name, int
> > zone->MR_zone_handler = handler;
> > #endif /* MR_CHECK_OVERFLOW_VIA_MPROTECT */
> >
> > + /*
> > + ** XXX this causes a memory leak if `zone' was not newly allocated.
> > + */
> > zone->MR_zone_bottom = base;
>
> I don't understand this; please expand the comment.
I have written:
/*
** XXX If `zone' is pulled off the free-list (rather than newly allocated)
** then zone->MR_zone_bottom will be pointing to a previously allocated
** memory region. Setting it to point to `base' therefore causes a memory
** leak. `base' should not be allocated in the first place if `zone' is
** to be reused. See also the workaround in MR_unget_zone().
*/
Peter
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list