b. Freeing Up Memory

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 19 - Miscellaneous Commands >

b. Freeing Up Memory

This section shows how to use the Free() command to release the resources (such as bitmaps, files) after using them to free up the memory.

 

 

Command Prototype

 

uint16_t Free(int16_t Handle)

 

Parameters

Description

Handle

Value received from LoadImageFile() command

 

 

Code

 

 

void setup()

{

/* Initialize CleO - needs to be done only once */

 CleO.begin();

 

/* Start building a screen frame */

 CleO.Start();

 CleO.BitmapJustification(MM);

 

/* Get the handle for bitmap file */

 int16_t hJPEG = CleO.LoadImageFile("@Pictures/ctg.jpg", 0);

 

/* Draw a bitmap at (160, 240) using hJPEG handle */

 CleO.Bitmap(hJPEG, 160, 240);

 

/* Display completed screen frame */

 CleO.Show();

 

/* Free bitmap handle */

 CleO.Free(hJPEG);

}

 

void loop()

{

}

 

 

Description

 

In the above code snippet, the Setup routine loads and draws the bitmap file. After using the resource (i.e. bitmap files), the Free() command is used to release the allocated resources using the bitmap handle. Use the @ symbol only when performing the file operation from the eFlash and not from the SD Card.