tracking VB class object memory usage 
Author Message
 tracking VB class object memory usage

Dear,

   How to track the memory size when creating or destroying a VB class
object?
Does Win32 API GlobalMemoryStatus can get it? I remember long time ago QBX
got MEM to tell you the memory usage but has been removed in VB.

   Thank you.

regards,
William.



Sun, 18 May 2003 09:30:42 GMT  
 tracking VB class object memory usage
Here's something that might help:  I pulled it from a kbase article some time ago
(sorry -- don't remember the article number). It will tell you the total memory
being used by your application.  As far as I know, psapi.dll, which contains the
GetProcessMemoryInfo function, is only available on NT and greater OS (in other
words, this will fail on 95, 98, ME)

' Types and declares used to retrieve current workingset
Private Type PROCESS_MEMORY_COUNTERS
    cb                          As Long
    PageFaultCount              As Long
    PeakWorkingSetSize          As Long
    WorkingSetSize              As Long
    QuotaPeakPagedPoolUsage     As Long
    QuotaPagedPoolUsage         As Long
    QuotaPeakNonPagedPoolUsage  As Long
    QuotaNonPagedPoolUsage      As Long
    PagefileUsage               As Long
    PeakPagefileUsage           As Long
End Type

Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function GetProcessMemoryInfo Lib "psapi.dll" (ByVal lHandle As
Long, ByVal lpStructure As Long, ByVal lSize As Long) As Integer

Public Function SysResourcesGetWorkingSet() As Variant
Dim lReturn As Long
Dim uMemory As PROCESS_MEMORY_COUNTERS

   lReturn = GetProcessMemoryInfo(GetCurrentProcess(), VarPtr(uMemory), Len
(uMemory))
   SysResourcesGetWorkingSet = uMemory.WorkingSetSize

End Function

Hope this helps.

Pribb

Quote:
-----Original Message-----
Dear,

   How to track the memory size when creating or destroying a VB class
object?
Does Win32 API GlobalMemoryStatus can get it? I remember long time ago QBX
got MEM to tell you the memory usage but has been removed in VB.

   Thank you.

regards,
William.

.



Sun, 18 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Tracking RunTime Memory Usage

2. Classes & Memory Usage

3. Object Memory Usage

4. Printer Object and Memory Usage

5. Connection Object and Memory Usage

6. ADO Causes 100% Memory Usage/Increases in VM Usage

7. Q: Memory Usage of Objects in VB5

8. Process CPU Usage/Memory Usage

9. Memory tracking tool for VB?

10. Managing Memory Usage in VB.Net

11. vb app memory usage

12. limiting cpu/memory usage in vb

 

 
Powered by phpBB® Forum Software