Click here to Skip to main content
15,915,324 members
Home / Discussions / Database
   

Database

 
GeneralWhere... Pin
KORCARI1-Jan-05 1:22
KORCARI1-Jan-05 1:22 
GeneralSQL Server does not exist or access denied Pin
nikneem200531-Dec-04 6:07
nikneem200531-Dec-04 6:07 
GeneralRe: SQL Server does not exist or access denied Pin
kings_131-Dec-04 7:51
kings_131-Dec-04 7:51 
GeneralRe: SQL Server does not exist or access denied Pin
Colin Angus Mackay31-Dec-04 15:26
Colin Angus Mackay31-Dec-04 15:26 
GeneralRe: SQL Server does not exist or access denied Pin
nikneem20051-Jan-05 4:00
nikneem20051-Jan-05 4:00 
GeneralRe: SQL Server does not exist or access denied Pin
nikneem20051-Jan-05 4:28
nikneem20051-Jan-05 4:28 
GeneralHuge Memory Consumption Pin
Developer567831-Dec-04 0:41
Developer567831-Dec-04 0:41 
GeneralRe: Huge Memory Consumption Pin
Mike Dimmick2-Jan-05 6:16
Mike Dimmick2-Jan-05 6:16 
You need to understand what the Task Manager columns measure, and how the system allocates memory. The 'Mem Usage' column indicates the process's working set size - the amount of the process's address space which is currently backed by physical memory. This value can change up or down depending on the demand from this or other processes, and isn't really a reflection of how much memory your process has actually allocated. This value includes pages that contain code and data from your process's executable and DLLs. It also includes pages that are shared with other processes, for example memory-mapped files. The sum of the Mem Usage column will normally exceed (Total Memory - Available - System Cache) because pages from memory-mapped files and DLLs are counted against every process that references them.

The system adjusts your process's working set based on memory demand and heuristics, trying to keep a pool of free memory to allow fast allocations without needing to scan all processes at the point memory is required, and to keep a reasonably-sized disk cache. If there's enough free memory, an increase of 50MB on this value is not important.

The 'VM Size' column shows the number of bytes allocated to your process (the same information is exposed through the Process: Private Bytes performance counter). However, this measures virtual memory allocations - pages of virtual address space allocated using VirtualAlloc. Because of how the heap works, this may not go down when you return memory to the heap (by calling free, using delete, etc).

The heap is a mechanism for allocating arbitrarily-sized blocks of memory. The heap has to get that memory from somewhere, and it does so by calling VirtualAlloc. Typically the initial heap allocation is 1MB; once this 1MB is exhausted, more virtual memory - typically not contiguous with earlier allocations - is allocated. In newer versions of Windows, the heap maintains free lists for blocks of memory of a given size; doing this allows the heap manager to allocate blocks smaller than that size quickly by taking the first block from the free list, rather than searching the heap for a block of the right size. When the block is freed, it is returned to the top of the free list, i.e. it will be the next block of this size to be allocated (this helps cache locality, typically).

The heap can become fragmented. Just like your hard disk, you can get into a situation where there's no room for a large allocation in the existing heap, since all the free blocks are smaller. The heap then has to grow to accommodate the large allocation, even if the total of all the free blocks is larger, because the heap cannot move allocated blocks around to find a larger free space. The best way to handle this is simply not to allocate so much memory.

I think you're looking at the Mem Usage column, and what you're seeing on the first query is simply ADO, the OLE DB provider for your database (MS Jet), your database being loaded into memory, and the heap growing to accommodate the allocations for the data. If you're using the MSDASQL provider, you've got more layers: the MSDASQL OLE DB provider for ODBC, the ODBC driver stack, and the ODBC MS Jet driver. If you are using MSDASQL you should consider using the Jet provider (Microsoft.Jet.OLEDB.4.0) instead.

I can see a few places where you're allocating more memory than you need. CString has constructors which take a wide-character (Unicode) string. Your intermediate casts to char*, when allocating csValue and m_csError, cause an extra allocation and, if you're compiling a Unicode build, an extra conversion each way. These should be unnecessary. Remember that BSTRs are always wide-character strings. If a cast is necessary, cast to LPCWSTR rather than char*.

You could also consider converting the return value of GetItem()->Value directly, rather than copying to an intermediate _variant_t. This copy operation causes the underlying string to be copied, if the variant already holds a string, which is unnecessary because you don't use the variant again after that.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: Huge Memory Consumption Pin
Developer56783-Jan-05 2:45
Developer56783-Jan-05 2:45 
GeneralHow Pin
KORCARI31-Dec-04 0:09
KORCARI31-Dec-04 0:09 
GeneralRe: How Pin
Rob Graham31-Dec-04 3:45
Rob Graham31-Dec-04 3:45 
GeneralWhere.... Pin
KORCARI31-Dec-04 0:06
KORCARI31-Dec-04 0:06 
GeneralMySQL GRANT SELECT Pin
alex.barylski30-Dec-04 15:09
alex.barylski30-Dec-04 15:09 
GeneralRe: MySQL GRANT SELECT Pin
WoutL31-Dec-04 0:46
WoutL31-Dec-04 0:46 
GeneralRe: MySQL GRANT SELECT Pin
Colin Angus Mackay31-Dec-04 15:46
Colin Angus Mackay31-Dec-04 15:46 
GeneralTOPLESS LADIES INSIDE - SQL Pin
HarryBo30-Dec-04 9:10
HarryBo30-Dec-04 9:10 
GeneralRe: TOPLESS LADIES INSIDE - SQL Pin
Javier Lozano1-Jan-05 13:44
Javier Lozano1-Jan-05 13:44 
GeneralOracle forms 6i problem Pin
missnazar30-Dec-04 4:00
missnazar30-Dec-04 4:00 
GeneralStored Procedure PRoblem Pin
percyvimal30-Dec-04 2:15
percyvimal30-Dec-04 2:15 
GeneralRe: Stored Procedure PRoblem Pin
Mike Dimmick30-Dec-04 3:50
Mike Dimmick30-Dec-04 3:50 
GeneralRe: Stored Procedure PRoblem Pin
abbaskaya30-Dec-04 4:29
abbaskaya30-Dec-04 4:29 
GeneralRe: Stored Procedure PRoblem Pin
abbaskaya30-Dec-04 4:30
abbaskaya30-Dec-04 4:30 
GeneralRe: Stored Procedure PRoblem Pin
percyvimal30-Dec-04 5:44
percyvimal30-Dec-04 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.