Skip to content

Commit 04f3cf6

Browse files
committed
free up dependencies
1 parent a8f2efe commit 04f3cf6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Runtime/LLMLib.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ public class LLMLib
367367
static bool has_avx = false;
368368
static bool has_avx2 = false;
369369
static bool has_avx512 = false;
370+
List<IntPtr> dependencyHandles = new List<IntPtr>();
370371

371372
#if (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
372373

@@ -498,8 +499,8 @@ public LLMLib(string arch)
498499
{
499500
foreach (string dependency in GetArchitectureDependencies(arch))
500501
{
501-
Debug.Log($"loading {dependency}");
502-
LibraryLoader.LoadLibrary(dependency);
502+
LLMUnitySetup.Log($"Loading {dependency}");
503+
dependencyHandles.Add(LibraryLoader.LoadLibrary(dependency));
503504
}
504505

505506
libraryHandle = LibraryLoader.LoadLibrary(GetArchitecturePath(arch));
@@ -759,6 +760,7 @@ public string GetStringWrapperResult(IntPtr stringWrapper)
759760
public void Destroy()
760761
{
761762
if (libraryHandle != IntPtr.Zero) LibraryLoader.FreeLibrary(libraryHandle);
763+
foreach (IntPtr dependencyHandle in dependencyHandles) LibraryLoader.FreeLibrary(dependencyHandle);
762764
}
763765
}
764766
}

0 commit comments

Comments
 (0)