I have a question UnityEngine.UI.ObjectPool<T> source code.

I have a question while looking at the source code.

https://bitbucket.org/Unity-Technologies/ui/src/7cba390c3078/UnityEngine.UI/UI/Core/Utility/ObjectPool.cs?at=5.2&fileviewer=file-view-default#ObjectPool.cs-41

In the Release function, use m_Stack.Peek to check if the object has already been released.
why use Peek without using the m_Stack.Containe function?

If use it like this, ObjectPool.countInactive is 3.
please answer about my question.

public class AAAA
    {
    }

    public class PoolTest
    {
        List<AAAA> m_AAA1 = ListPool<AAAA>.Get();
        List<AAAA> m_AAA2 = ListPool<AAAA>.Get();

        public void Init()
        {

        }

        public void Clear()
        {
            ListPool<AAAA>.Release(m_AAA1);
            ListPool<AAAA>.Release(m_AAA2);
            ListPool<AAAA>.Release(m_AAA1);
        }
    }

It might be too late to answer this question.
But you should not hold the reference of List fetched from list pool.
Get() and use it, them immediately release it back to pool.

Contain() is searching the whole pool which is much slower than just checking the Peek().

The pool is a simple helper which is made to avoid allocating memory for list frequently.
If your class needs a List object and must hold the reference, you should new a List().