Hi Everyone,

I was playing around with a patch to replace SWIG with PyBind a couple
of weeks ago and found some "interesting" memory allocation issues.

My understanding of event ownership is as follows:

 * !IsExitEvent && AutoDelete: Owned by the event queue.
 * !IsExitEvent && !AutoDelete: Owned by the object that scheduled them.
 * IsExitEvent && AutoDelete: Illegal.
 * IsExitEvent && !AutoDelete: Unclear

Exit events, unlike normal events, are returned by the event queue after
they have been serviced. For the main queues, these events eventually
make their way into Python land. The question is what happens next.

Originally, my assumption was that the caller of simulate() (or
EventQueue::serviceOne) owns the returned object. This is the case for
non-repeating exits scheduled using exitSimLoop(). Repeating events on
the other hand mustn't be deleted.

Additionally, some other non-repeating exit events are owned created
once and then rescheduled. At least the limit event in sim/simulate.cc
is only created once and then rescheduled every time simulate() is
called. I wouldn't be surprised if this happens in other places as well.

The only obvious solution I can think of for this problem is to
implement reference counting for global events. This would need a fairly
substantial redesign of global even handling though, but it would fix
the obvious memory leaks.

Any thoughts/ideas?

Thanks,
Andreas

IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to