Out of Memory error while loading bitmap

Discussion in 'Questions (Windows Mobile)' started by HARRY, May 15, 2007.

  1. HARRY

    HARRY Active Member Licensed User

    Hi,

    In a program I load three new bitmaps each time when the user clicks on a table. Each bitmap has a size of 320 *240 and is displayed with a size of 80 * 60.

    The code used to load and display the three bitmaps is:

    bmpsrc1.New1(PhotoPath & Photo1)
    drawer1.DrawImage1(bmpsrc1.Value,rectsrc1.Value,rectdes1.Value,true)
    drawer1.Refresh2(rectdes1.Value)

    bmpsrc2.New1(PhotoPath & Photo2)
    drawer2.DrawImage1(bmpsrc2.Value,rectsrc2.Value,rectdes2.Value,true)
    drawer2.Refresh2(rectdes2.Value)

    bmpsrc3.New1(PhotoPath & Photo3)
    drawer3.DrawImage1(bmpsrc3.Value,rectsrc3.Value,rectdes3.Value,true)
    drawer3.Refresh2(rectdes3.Value)


    On the PDA only, after 21 clicks I get the error message: OutOfMemoryException on the line bmpsrc3.New1(PhotoPath & Photo3)

    I fear that each bmpsrc*.New1 statement claims additional memory, but I do not know:

    1) How to free the memory used by previous bitmaps.

    2) What the maximum size is of the memory made available for an application.

    Please some help.


    Harry
     
  2. Cableguy

    Cableguy Expert Licensed User

    I think that all libs have a dispose property, so you can ...dispose.... of the previous image before showing the new one....
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    I understand that each time the bitmaps are loaded with three new files.
    You can try:
    bmpSrc.Dispose
    AddObject("bmpSrc","Bitmap")
    BmpSrc.New1 (...)
     
  4. HARRY

    HARRY Active Member Licensed User

    Erel, Paulo,

    Thanks for your help. I exercised already with dispose, but forgot to add the object again.

    Harry
     
Loading...