I’ve created ILockBytesOnHGlobal and I write 64k of data repeatedly. What I’ve noticed is that WriteAt performance decreases over the time.
What could be the reason for the performance slow down?
Does it have to do with stream growth?
Here is what I’m doing (in C#)
public override void Write(byte[] buffer, int offset, int count)
{
EnsureBufferSize(count);
Marshal.Copy(buffer, offset, hGlobalBuffer, count);
lockBytes.WriteAt(writeOffset, hGlobalBuffer, count, out temp);
writeOffset += temp.ToUInt32();
}
CreateILockBytesOnHGlobaldocumentation says that it usesGlobalReAllocto increase the memory block.GlobalReAlloccopies the data from the old memory block to the new (and larger) memory block, so this causes performance to go down over time.