Replies: 4 comments
-
Hi, thanks for the comment. If Try: public static readonly Func<object>[] authTables = new Func<object>[]
{
FastNew.GetCreateInstance<object>(Type.GetType(typeof(User).FullName + ", MyAssemblyName")),
FastNew.GetCreateInstance<object>(Type.GetType(typeof(UserInfo).FullName + ", MyAssemblyName"))
};
public static void CreateTablesInDB(SqliteConnection con, Func<object>[] tables)
{
foreach (var table in tables)
{
var instanceTable = table();
// here do some stuff with my instanceTable....
string strCreateTable = ClassToDDL(instanceTable, "create");
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi, I made the changes and I have memory leak when I call Any suggestions? Thank you; |
Beta Was this translation helpful? Give feedback.
-
Is the object you created implemented public static void CreateTablesInDB(SqliteConnection con, Func<object>[] tables)
{
foreach (var table in tables)
{
var instanceTable = table();
// here do some stuff with my instanceTable....
string strCreateTable = ClassToDDL(instanceTable, "create");
(instanceTable as IDisposable)?.Dispose();
}
} It can also be caused by the constructor code of the object. And here are some tips about how to fix memory leaking problems: Hope this can help you out :) |
Beta Was this translation helpful? Give feedback.
-
Hi, thank you for your answer :) It implement I added it and I added Sadly I'm working in Linux so I don't have VisualStudio installed. Instead I use VSCode. I will came back to you when I will have more news. Thank you again. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have a specific setup where I'm using Activator.CreateInstance.
Because I have a memory leak I want to try your approach.
But I'm not an expert so I want to ask you help to understand how to do it.
Here my current code
I have an array of class name like this one:
and I give it to my method (in tables):
User and UserInfo are my classes.
My question is: Can I use your approach? In which way?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions