Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for usage of ListBuffer to be properly released #681

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ public object SpawnInstance(IObjectResolver resolver)
}
else if (scene.IsValid())
{
var gameObjectBuffer = UnityEngineObjectListBuffer<GameObject>.Get();
scene.GetRootGameObjects(gameObjectBuffer);
foreach (var gameObject in gameObjectBuffer)
using (UnityEngineObjectListBuffer<GameObject>.Get(out var gameObjectBuffer))
{
component = gameObject.GetComponentInChildren(componentType, true);
if (component != null) break;
scene.GetRootGameObjects(gameObjectBuffer);
foreach (var gameObject in gameObjectBuffer)
{
component = gameObject.GetComponentInChildren(componentType, true);
if (component != null) break;
}
}
if (component == null)
{
Expand Down
14 changes: 8 additions & 6 deletions VContainer/Assets/VContainer/Runtime/Unity/LifetimeScope.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,15 @@ public static ExtraInstallationScope Enqueue(IInstaller installer)

static LifetimeScope Find(Type type, Scene scene)
{
var buffer = UnityEngineObjectListBuffer<GameObject>.Get();
scene.GetRootGameObjects(buffer);
foreach (var gameObject in buffer)
using (UnityEngineObjectListBuffer<GameObject>.Get(out var buffer))
{
var found = gameObject.GetComponentInChildren(type) as LifetimeScope;
if (found != null)
return found;
scene.GetRootGameObjects(buffer);
foreach (var gameObject in buffer)
{
var found = gameObject.GetComponentInChildren(type) as LifetimeScope;
if (found != null)
return found;
}
}
return null;
}
Expand Down