Well, I don't get why you need to know how much reference counting an object currently has. You are entirely denying the technique of memory management by reference counting. What developers need to pay attention to is that they don't forget to free a memory when it isn't needed anymore after allocation. Another point is, there is no way to know what objects are really used or not. introducing such functions may introduce unexpected behavior. freeing all the FcPattern instances at exiting, as you proposed at https://gitlab.gnome.org/GNOME/pango/-/issues/750 doesn't fix anything for users because unwanted memory still keeps allocated as long as it keeps running. What if it is huge and often happens? Do you suggest restarting apps so often and many times? I don't get anything useful on it. so I'm afraid I disagree. On Mon, Jun 5, 2023 at 5:19 PM Frederick Virchanza Gotham <cauldwell.thomas@xxxxxxxxx> wrote: > > I propose adding the following function to libfontconfig: > > int FcPatternRefCount(FcPattern const *const p) > { > if ( !p ) return 0; > return p->ref.count; > } > > so that we can destroy an FcPattern as follows: > > while ( FcPatternRefCount(p) ) FcPatternDestroy(p); > > Actually just as I'm writing this, I realise that there would be a > race condition if two threads are simultaneously calling > FcPatternRefCount. So instead maybe just have: > > int FcPatternDestroyAll(FcPattern*); > > which would destroy them all. -- Akira TAGOH