stride3d/stride · error · ArgumentException
The Graphics Resource was not allocated by this allocator
Error message
The Graphics Resource was not allocated by this allocator
What it means
UpdateReference looks up the resource in the allocator's per-type caches (textureCache, bufferCache, queryPoolCache). If the resource is a supported type but was never allocated by (or registered with) this allocator instance, resourceFound is false and an ArgumentException naming 'resource' is thrown. Each allocator only manages resources it created itself.
Solutions
- Allocate the resource through this same GraphicsResourceAllocator instance (AllocateTexture/AllocateBuffer/etc.) before adding references.
- Verify you are passing the allocator instance that originally created the resource.
- Check the resource has not already been released and removed from the allocator's cache.
- Track a 'recycled' resource by its new incarnation from the allocator rather than a stale reference.
Example fix
// before var buffer = Buffer.New(graphicsDevice, size); allocator.AddReference(buffer); // throws: not allocated by allocator // after var buffer = allocator.AllocateBuffer(new BufferDescription(size), bufferPool);
Defensive patterns
Strategy: validation
Validate before calling
if (!allocator.OwnsResource(texture)) // or track allocations yourself
throw new InvalidOperationException("Resource must be allocated by this allocator");
allocator.AddReference(texture); Type guard
bool AllocatedByThis(Allocator a, GraphicsResourceBase r) => r.Allocator == a;
Try / catch
try { allocator.ReleaseReference(resource); }
catch (ArgumentException ex) { log.Warn("resource not owned by allocator", ex); } Prevention
- Allocate resources through the same allocator that releases them
- Keep one allocator per device/pipeline scope
- Never manually release already-recycled temporaries
When it happens
Trigger: Calling AddReference/ReleaseReference with a Texture/Buffer/QueryPool that was created by another allocator, created manually (e.g. Buffer.New directly), or already fully released and evicted from the cache.
Common situations: Mixing resources between two allocator instances (e.g. one per GraphicsDevice or scene); creating buffers/textures outside the allocator then trying to reference-count them; double-releasing a temporary resource that has since been recycled.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Binding describes an array larger than dataOuter
- Binding describes an array larger than dataOuter
- Cannot generate more than 65535 indices on feature level HW…
- Control points apply only to PrimitiveType.PatchList
- destination length does not match the amount of indices…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/11e8f49be29fc711.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/GraphicsResourceAllocator.cs:477
/// </exception>
private void UpdateReference(GraphicsResourceBase resource, int referenceDelta)
{
if (resource is null)
return;
bool resourceFound = false;
resourceFound = resource switch
{
Texture texture => UpdateReferenceCount(textureCache, texture, GetTextureDescription, referenceDelta),
Buffer buffer => UpdateReferenceCount(bufferCache, buffer, GetBufferDescription, referenceDelta),
QueryPool queryPool => UpdateReferenceCount(queryPoolCache, queryPool, GetQueryPoolDescription, referenceDelta),
_ => throw new ArgumentException("Unsupported Graphics Resource. Only Textures, Buffers and QueryPools are supported", nameof(resource))
};
if (!resourceFound)
throw new ArgumentException("The Graphics Resource was not allocated by this allocator", nameof(resource));
}
/// <summary>
/// Updates the reference count for a specified Graphics Resource.
/// </summary>
/// <typeparam name="TResource">The type of the Graphics Resource.</typeparam>
/// <typeparam name="TDescription">The type of an object that describes the characteristics of the Graphics Resource.</typeparam>
/// <param name="cache">The cache of allocated Graphics Resources of the intended type.</param>
/// <param name="resource">The Graphics Resource whose reference count is to be updated.</param>
/// <param name="getDescription">
/// A delegate that retrieves the actual description of a Graphics Resource.
/// See <see cref="GetTextureDescription"/>, <see cref="GetBufferDescription"/>, or <see cref="GetQueryPoolDescription"/> for examples.
/// </param>
/// <param name="referenceDelta">
/// The change in the reference count. Positive values increase the count, while negative values decrease it.
/// </param>
/// <returns>
/// <see langword="true"/> if the reference count for <paramref name="resource"/> was updated; <see langword="false"/> otherwise.View on GitHub (pinned to 96fad776d2)