UltraLite database cache sizes increase dynamically in response to data operations and as available device memory allows within the parameters you specify. Normally you do not need to specify any parameters. If your database is large (400 MB for instance), you may want to specify the CACHE_MAX_SIZE parameter to raise the maximum limit beyond the default. UltraLite allocates some data structures based on the maximum cache size, so the default is not extremely large: you must explicitly request a large maximum to incur this extra memory overhead. There is no benefit to specifying a maximum cache size that is much larger than your maximum actual database file size.
Dynamic cache sizing is not supported by UltraLite Java edition databases. For more information about UltraLite Java edition database cache sizes, see UltraLite Java edition database cache sizes.
Although explicitly adjusting the cache sizing is not required, you typically want to adjust the cache size when your UltraLite database application is requested to reduce its memory usage by the operating system on mobile devices.
UltraLite does not shrink the cache automatically. The database cache size can only be controlled explicitly in your application with the cache_allocation database option.
This procedure illustrates the dynamic cache sizing functionality using the UltraLite C++ API as an example. It assumes that you want to update an existing C++ application to explicitly control the cache size.
Update the connection string used to connect to your UltraLite database to set your cache size limits.
In this example, you set the maximum cache size to 100 MB:
static ul_char const * ConnectionParms = "UID=DBA;PWD=sql;DBF=sample.udb;CACHE_MAX_SIZE=100m";
In response to a low memory event raised by the operating system, adjust the cache_allocation database option after connecting to the database.
In this example, you reduce the cache allocation in half to resize the cache using the following code:
ULConnection * conn = ULDatabaseManager::OpenConnection(ConnectionParms); ul_u_long percent; percent = conn->GetDatabasePropertyInt( "cache_allocation" ); conn->SetDatabaseOptionInt( "cache_allocation", percent / 2 );
Discuter à propos de cette page dans DocCommentXchange.
|Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1|