Esempio n. 1
0
        public static void DrainObjectCopyPool()
        {
            // Objects in the pool have been created by Cocoa, so there should be no managed references
            // other than the ones we keep in the pool. An object can be removed from the pool if it
            // has only 1 reference left (the managed one)

            List <NSObject> markedForDelete = new List <NSObject> ();

            foreach (NSObject ob in copyPool)
            {
                uint count = Messaging.UInt32_objc_msgSend(ob.Handle, selRetainCount.Handle);
                if (count == 1)
                {
                    markedForDelete.Add(ob);
                }
            }
            foreach (NSObject ob in markedForDelete)
            {
                copyPool.Remove(ob);
            }

            lastCopyPoolDrain = DateTime.Now;
        }