I have a problem that has been bothering me for several days now. I tried to solve the Google problem, but still could not find any solutions, not even one person with the same problem.
It seems that the C # System.Buffer.BlockCopy method leaves you with some ghosts of memory. I have, for example, this method:
private float[,] readFloatArray2 (byte[] b) { int floatSize = sizeof(float); float[,] v = new float[2, (b.Length / 2) / floatSize]; System.Buffer.BlockCopy(b, 0, v, 0, b.Length); return v; }
to convert an array of bytes to an array of 2D float. Data is pre-read from the stream. I found the problem as a System.Buffer.BlockCopy method.
If I remove the BlockCopy command, the memory used by the application will be half as much. this means it's not my fault that the byte array is still alive. because without the BlockCopy command, the byte array fits correctly. a float is created anyway (with or without copied information).
I'm not quite sure if this is a problem with the BlockCopy or GC command, because I also tried calling System.GC.Collect (); after BlockCopy and then it works great (I know you shouldn't do this ... that's why I ask for advice here).
I also would not ask, but the problem includes several hundred mega.
In addition to memory issues, the method works just fine. Does anyone know what causes a memory problem?
greetings and thanks in advance oli
ps: I am using .NET4.0 with Visual Studio 2010 PRO and WIN7 ... I donβt know how relevant or not.