locked
OutOfMemoryException RRS feed

  • Question

  • Hi, I am programming an application for Windows Mobile 6.1 using .Net CF 3.5. My program throws an OutOfMemoryException when I try to read a .png from the smartphone's Internal Storage. The .png is not that big. It takes up 80Kb of storage space. The offending line of code is:

    System.Drawing.Bitmap image = new System.Drawing.Bitmap(path);

    I figured that my program must just be eating up all the available memory, so I have run

    GC.Collect();

    Immediately before the call, to no avail. I then also call:

    long memUsed = GC.GetTotalMemory(true);

    to find out how much memory I use immediately before loading the Bitmap. The number it returns is 267096. I assume that this means that I am using 267096 bytes of RAM at that point.

    I am using a HTC Diamond Touch as my test platform. Right before my program starts I have 135.00 MB of "Program" memory free and 60.66 MB of"Storage" memory free.

    Given the amount of free memory, the small amount I use before calling the Bitmap constructor, and the size of the image's file, I don't see how I can be running out!

    Can anyone please let me know what I am doing wrong? Are there are tutorials about memory management in the Compact Framework? Are there any pitfalls which I am neglecting to avoid? Are there any nice tools which can help?

    Thanks!




    Sunday, November 2, 2008 7:16 PM

Answers

All replies