Amplifier.NET icon indicating copy to clipboard operation
Amplifier.NET copied to clipboard

OutOfMemory

Open Yoticc opened this issue 3 years ago • 8 comments

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 image image image

Yoticc avatar Jul 08 '22 23:07 Yoticc

If you need my code: image Kernel: image

Yoticc avatar Jul 08 '22 23:07 Yoticc

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

deepakkumar1984 avatar Jul 09 '22 14:07 deepakkumar1984

Hello, how are you?

Yoticc avatar Jul 29 '22 13:07 Yoticc

How are things with this error?

Yoticc avatar Aug 06 '22 03:08 Yoticc

@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

deepakkumar1984 avatar Aug 15 '22 11:08 deepakkumar1984

Good, https://dropmefiles.com/TCBa9 - Net 6.0 Calculate is part with GPU Calculating

Yoticc avatar Aug 16 '22 03:08 Yoticc

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);
}

Yoticc avatar Aug 16 '22 11:08 Yoticc

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

deepakkumar1984 avatar Aug 16 '22 11:08 deepakkumar1984