EllanJiang/GameFramework · error · GameFrameworkException

Results is invalid.

Error message

Results is invalid.

What it means

GetCanReleaseObjects fills a caller-provided List<T> with objects eligible for release. A null list cannot be filled, so the pool throws 'Results is invalid.' The list is reused by CanReleaseCount, Release(count, filter) and ReleaseAllUnused to avoid allocations.

Solutions

  1. Always construct and pass a valid List<T> instance (it may be empty; it is cleared first).
  2. In custom code, prefer the public Release/CanReleaseCount APIs which allocate the list correctly.
  3. If maintaining a fork, add lazy initialization: results ??= new List<T>().

Example fix

// before
List<T> results = null;
GetCanReleaseObjects(results);
// after
List<T> results = new List<T>();
GetCanReleaseObjects(results);
Defensive patterns

Strategy: validation

Validate before calling

var results = new List<T>();
if (results != null)
{
    GetCanReleaseObjects(results);
}

Try / catch

try { GetCanReleaseObjects(results); }
catch (GameFrameworkException) { /* results list was null; allocate and retry */ }

Prevention

When it happens

Trigger: Internal call paths passing a non-initialized list — practically triggered if subclass/modified code overrides or invokes this private helper with null, or custom builds call it directly.

Common situations: Custom forks of GameFramework extending ObjectPool with their own release logic; reflection-based tooling invoking private methods with incomplete arguments.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/e23670c4a656488e. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/ObjectPool/ObjectPoolManager.ObjectPool.cs:581

                if (target == null)
                {
                    throw new GameFrameworkException("Target is invalid.");
                }

                Object<T> internalObject = null;
                if (m_ObjectMap.TryGetValue(target, out internalObject))
                {
                    return internalObject;
                }

                return null;
            }

            private void GetCanReleaseObjects(List<T> results)
            {
                if (results == null)
                {
                    throw new GameFrameworkException("Results is invalid.");
                }

                results.Clear();
                foreach (KeyValuePair<object, Object<T>> objectInMap in m_ObjectMap)
                {
                    Object<T> internalObject = objectInMap.Value;
                    if (internalObject.IsInUse || internalObject.Locked || !internalObject.CustomCanReleaseFlag)
                    {
                        continue;
                    }

                    results.Add(internalObject.Peek());
                }
            }

            private List<T> DefaultReleaseObjectFilterCallback(List<T> candidateObjects, int toReleaseCount, DateTime expireTime)
            {
                m_CachedToReleaseObjects.Clear();

View on GitHub (pinned to d0c010b051)