I have a small webserver application I am working on, and may have an issue with the allocation of memory for ‘byte[]’. I posted a more general query about my webserver issue in the ‘Gadgeteer’ board, figuring I just needed a little help. After looking at the issue some more, I’m thinking this could be a beta bug. I am using a Cerberus, updated to 7/23 SDK, with the network image loaded and an SD card attached.
When I try to allocate space with byte[] I get debugger messages such as:
Failed allocation for 198 blocks, 2376 bytes
Failed allocation for 172 blocks, 2064 bytes
I guess it’s possible I’m running short on memory, but if that’s the case something is using a lot more than I think as I don’t think I have any large objects. Here is the code I’m executing:
{
// Writes data to browser
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
byte[] buf = new byte[fs.Length]; // Works at 4000 and below, does Not work at 5000?!?!?
fs.Read(buf, 0, buf.Length);
responder.Respond(buf, ContentType);
fs.Dispose();
Debug.Print("File served...");
}
Just how big can a byte[] array be? If I am limited on memory, what items related to networking or SD cards eat the most? And finally, is there another way to tackle this file size issue within Gadgeteer?
Thanks in advance, this stuff is really pretty cool…