Page 1 of 1

WIKI AllocSysObject ASO_NoTrack clarification

Posted: Sun Nov 23, 2014 8:32 pm
by xenic
The autodoc for AllocSysObject says this about the ASO_NoTrack option:
  • ASO_NoTrack: A boolean value that indicates
    whether the object should be tracked or not.

    This might be useful for stuff that is dangrous
    to get rid of automatically, like semaphores.
    Also, tracking has a slight additional memory overhead.
    Default: TRUE (i.e do not track)
That explanation is a little ambiguous to me. Is it useful to track or not track for things that are dangerous to get rid of automatically? Does this mean that selecting ASO_NoTrack TRUE would mean that memory allocated for the name of a semaphore that is copied by ASOT_SEMAPHORE ASOSYM_Copyname will not be tracked and freed automatically when FreeSysObject() is called? Also, why is it dangerous to get rid of a semaphore automatically?

Re: WIKI AllocSysObject ASO_NoTrack clarification

Posted: Mon Nov 24, 2014 4:28 am
by Hans
@xenic

FreeSysObject() will always fully free an object (incl. memory). Tracking enables objects to be automatically cleaned up when a task/process ends. I assume that tracked objects are also automatically cleaned up after a task has been terminated due to crashing, but I'm not 100% sure.

Since semaphores are used for synchronization between multiple tasks, automatically freeing it when the task that created it stops could be risky. Other tasks that use that semaphore might try to access it after it's been freed.

I see tracking as a backup for when things go wrong, and believe that software should still manually free all objects before exiting. Not doing so is kind of lazy.

Hans