OutOfMemory
I wrote a program that calculates 1875000 int on CPU/GPU with your library every second, I pass this via [GLOBAL].
You forgot to add Free for GCHandle somewhere, which causes the memory to overflow, after 20 minutes and 10GB of used memory, the program crashes due to OutOfMemory

If you need my code:
Kernel:

Thanks for the sample code. I will have a look next week.
Regards, Deepak
On Sat, Jul 9, 2022 at 9:29 AM Yotic @.***> wrote:
If you need my code: [image: image] https://user-images.githubusercontent.com/55879406/178083243-054a4389-112e-4986-beac-1307d99a2ab3.png Kernel: [image: image] https://user-images.githubusercontent.com/55879406/178083251-21734282-7ba7-4bd1-b22e-c7e2fbbe59f6.png
— Reply to this email directly, view it on GitHub https://github.com/deepakkumar1984/Amplifier.NET/issues/20#issuecomment-1179435201, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQJAKOPHS2YMW6VAATAQZLVTC6HPANCNFSM53COFYEA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
-- Regards, Deepak
Hello, how are you?
How are things with this error?
@MrYotic Can you please send your code in a file? I am making mistakes with your code. It will be easy if you send me in a file
Good, https://dropmefiles.com/TCBa9 - Net 6.0 Calculate is part with GPU Calculating
I was able to solve this problem, the memory leak is completely gone. For the most part, it was not in your library, but in my code. So, every iteration I created a new big array, but because somewhere in your code there was a reference to this array, the GC could not clear it, so a bunch of large ones accumulated array. I think this can be solved through the library, so that other people do not have such an error in the future. As exapmple bad code with memory leak:
while(true)
{
int[] args = new int[1750000];
kernel.Exec(args);
}
As exapmple bad code without memory leak:
int[] args;
while(true)
{
args = new int[1750000];
kernel.Exec(args);
}
Thanks mate for the confirmation
On Tue, Aug 16, 2022 at 9:04 PM Yotic @.***> wrote:
I was able to solve this problem, the memory leak is completely gone. For the most part, it was not in your library, but in my code. So, every iteration I created a new big array, but because somewhere in your code there was a reference to this array, the GC could not clear it, so a bunch of large ones accumulated array. I think this can be solved through the library, so that other people do not have such an error in the future. As exapmple bad code with memory leak:
while(true) { int[] args = new int[1750000]; kernel.Exec(args); }
As exapmple bad code without memory leak:
int[] args; while(true) { args = new int[1750000]; kernel.Exec(args); }
— Reply to this email directly, view it on GitHub https://github.com/deepakkumar1984/Amplifier.NET/issues/20#issuecomment-1216513847, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABQJAKL35GV23Q6I7SQED5DVZN4E3ANCNFSM53COFYEA . You are receiving this because you commented.Message ID: @.***>
-- Regards, Deepak