Hello,
in the last time we encounter more and more the problem that CEDB grows up infinite. After some investigations we saw that the launch of some .NET applications causes this problem. We were not able to isolate the area within the .NET application which causes the problem until now. But we checked CEDB and find that one entry for "repllog.exe" is inserted after each reboot. This behavior may slow down the system (e.g. ActiveSync does not connect any more ...).
Use the following workaround to prevent growing of CEDB.
1. check CEDB for multiple entries
2. delete the multiple entries
Sample code
C
- #include "stdafx.h"
- #include <windows.h>
- #include <commctrl.h>
- #include <afx.h>
- CEOID DBqueue;
- WORD QueueRecs = 0;
- CEOID DBevents;
- WORD EventRecs = 0;
- void CheckFor_DB_notify(void);
- void CheckAndDelete_DB_notify_multiple(void);
- int _tmain(int argc, _TCHAR* argv[])
- {
- // List the avail. DBs
- CheckFor_DB_notify();
- // Check "DBevents" for multiple entries and delete them
- if(DBevents != 0)
- CheckAndDelete_DB_notify_multiple();
- // TODO: check next DB ...
- return 0;
- }
- // ******************************************************************************
- // List DBs and chech access to "DBevents"
- void CheckFor_DB_notify()
- {
- HANDLE FoundDB;
- CEOID CurrentOID;
- CEOID ceoidRet=0;
- CString sQueue =_T("DB_notify_queue");
- CString sEvents =_T("DB_notify_events");
- FoundDB = CeFindFirstDatabaseEx(NULL, 0);
- if(FoundDB == INVALID_HANDLE_VALUE)
- {
- RETAILMSG( 1, (TEXT("No Databases found\r\n")));
- }
- else
- {
- while( CurrentOID = CeFindNextDatabaseEx( FoundDB, 0 ) )
- {
- CEOIDINFO OIDInfo;
- RETAILMSG( 1, (TEXT("Database found\n")));
- if(CeOidGetInfoEx(NULL, CurrentOID, &OIDInfo))
- {
- if(OIDInfo.wObjType == OBJTYPE_DATABASE)
- {
- RETAILMSG(1, (TEXT(" Database: %s\r\n"), OIDInfo.infDatabase.szDbaseName ));
- RETAILMSG(1, (TEXT(" Size: %d\r\n"), OIDInfo.infDatabase.dwSize ));
- RETAILMSG(1, (TEXT(" Records: %d\r\n"), OIDInfo.infDatabase.wNumRecords ));
- if (sQueue.CompareNoCase(OIDInfo.infDatabase.szDbaseName) == 0)
- {
- DBqueue = CurrentOID;
- QueueRecs = OIDInfo.infDatabase.wNumRecords;
- }
- else if (sEvents.CompareNoCase(OIDInfo.infDatabase.szDbaseName) == 0)
- {
- DBevents = CurrentOID;
- EventRecs = OIDInfo.infDatabase.wNumRecords;
- }
- }
- else
- RETAILMSG( 1, (TEXT("Failed to get info for this database\r\n")));
- }
- }
- CloseHandle( FoundDB );
- }
- }
- // ******************************************************************************
- // Check "DBevents" for multiple entries and delete them
- void CheckAndDelete_DB_notify_multiple(void)
- {
- CEGUID guid;
- CREATE_SYSTEMGUID(&guid);
- HANDLE hDatabase = CeOpenDatabaseEx2(&guid, &DBevents, NULL,NULL,CEDB_AUTOINCREMENT, NULL);
- if(hDatabase != INVALID_HANDLE_VALUE)
- {
- WORD wPropId = 0;
- CEPROPVAL* Buffer = NULL;
- DWORD dwSizeOfBuffer = 0;
- CEOID ceoidRecord;
- DWORD checked=0;
- DWORD deleted = 0;
- while (ceoidRecord = CeReadRecordPropsEx(hDatabase, CEDB_ALLOWREALLOC, &wPropId, /*Number of properties*/NULL,
- (LPBYTE*) &Buffer, &dwSizeOfBuffer, NULL/*hHeap*/))
- {
- CEPROPVAL* BufferCmp = NULL;
- DWORD dwSizeOfBufferCmp = 0;
- WORD wPropIdCmp = 0;
- for(WORD i=0 ;i<EventRecs-1-checked-deleted; i++)
- {
- CEOID ceoidRecordCmp = CeReadRecordPropsEx(hDatabase, CEDB_ALLOWREALLOC,
- &wPropIdCmp, /*Number of properties*/NULL, (LPBYTE*)&BufferCmp, &dwSizeOfBufferCmp, /*hHeap*/NULL);
- if( ceoidRecordCmp && wcscmp(Buffer->val.lpwstr,BufferCmp->val.lpwstr) == 0 /*&& TODO: do additional
- comparison checks*/)
- {
- RETAILMSG( 1, (TEXT("Found duplicate entries: %s - %s\r\n"),Buffer->val.lpwstr,BufferCmp->val.lpwstr));
- if(CeDeleteRecord(hDatabase, ceoidRecordCmp))
- {
- RETAILMSG( 1, (TEXT("Delete duplicate entry: %s\r\n"),BufferCmp->val.lpwstr));
- deleted++;
- checked--;
- break;
- }
- else
- RETAILMSG( 1, (TEXT("Error while delete duplicate entry, error: %d\r\n"),GetLastError()));
- }
- }
- checked++;
- LocalFree(BufferCmp);
- if(CeSeekDatabaseEx(hDatabase, CEDB_SEEK_BEGINNING, checked, 0, NULL)==0)
- {
- RETAILMSG( 1, (TEXT("Error while seek db, error: %d\r\n"),GetLastError()));
- }
- }
- RETAILMSG( 1, (TEXT("%d Records deleted from DB_notify_events\r\n"),deleted));
- LocalFree(Buffer);
- CloseHandle(hDatabase);
- }
- }