Memory Storage Types for Bitmaps

There are several types of bitmaps:

You can specify the type of bitmap you want when you call LBitmapBase::Create or LBitmapBase::Allocate. You can also instruct LEADTOOLS to react dynamically depending on the bitmap size or the amount of available memory using LMemoryFile::SetMemoryThresholds.

When LEADTOOLS has to allocate a conventional bitmap, it does the following:

  1. If the size of the bitmap being allocated is less than the fixed tile size (set through LMemoryFile::SetMemoryThresholds when uTileSize is > 0), the bitmap is allocated as conventional. If the allocation fails, the memory allocation function fails. If the allocation succeeds, the memory allocation function returns SUCCESS. No other steps are executed.

  2. Checks the maximum size for a conventional bitmap (set through LMemoryFile::SetMemoryThresholds). If the size of the bitmap being allocated is greater than this threshold, a tiled bitmap will be allocated. Go to step 5. If the size of the bitmap being allocated is lower than the threshold, go to step 3.

  3. Checks whether there is enough available memory to allocate a conventional bitmap. (This threshold is also set through LMemoryFile::SetMemoryThresholds). If there is not enough free memory, a tiled bitmap will be allocated and go to step 5. Else, go to step 4.

  4. Try to allocate a conventional memory bitmap (bitmap which is contained entirely in conventional memory. If the allocation succeeds, the memory allocation returns success and no other steps are performed. If the allocation fails, go to step 5.

  5. Try to allocate a tiled bitmap. There can be a mix of disk and conventional memory tiles. If the function succeeds, the allocation function returns success and no other steps are performed. If the allocation fails, go to step 6.

  6. Try to allocate a tiled bitmap. Return success if the allocation succeeds, error otherwise.

To get the memory threshold information set by LMemoryFile::SetMemoryThresholds, call LMemoryFile::GetMemoryThresholds.

By default, the Windows temporary directory is used to store the disk files used for the disk tiles and disk images. You can change the location where these files are stored using LFileSettings::SetTempDirectory. You can get the current location using LFileSettings::GetTempDirectory.

Even when you have lots of RAM and enough space in the swap file, Windows might fail to allocate you one contiguous chunk of conventional memory. In this case, the bitmap will be allocated as tiled or disk.

Example: You attempt to allocate a 512MB bitmap. Windows might fail to allocate a contiguous 512MB memory chunk, but it might be able to allocate you 2x 256 MB chunks or 4x 128 MB chunks. In this case, LEADTOOLS allocates your 512MB bitmap using several smaller chunks in a tiled bitmap.

In a more extreme case, you might have not enough space to allocate the whole bitmap in conventional memory. Or you might have specified a maximum amount of conventional memory to be used with a bitmap. In either of these cases, LEADTOOLS will try to allocate a tiled bitmap with some tiles in conventional memory and others on disk.

The conventional memory tiles are always accessible (read further to see why this matters). Disk tiles will still need some chunks of conventional memory to read from disk/write to disk. We will refer to these chunks as "views". The more views you have, the more disk tiles can be accessed at a time and the faster the working with the bitmap will be. When you read or read from a disk tile, data is being cached to the view and no disk access is performed unless you move to another tile. The "move to another tile" operation is performed automatically when you read or write data to a certain row.

When you go to a disk tile that has no view, LEADTOOLS will:

You can find out the memory allocation parameters for a bitmap using LMemoryFile::GetBitmapMemoryInfo. You can change the memory allocation parameters using LMemoryFile::SetBitmapMemoryInfo. The memory parameters are:

These are for tiled bitmaps only:

See Also

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.