Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My favourite tool has to be DevPartner though at £1,500 a pop it is not cheap. It does a hell of a lot more than Memory leak checking though, but if that's all you need you might be carpet bombing ants.</p> <p>If you want to see if your app is releasing resources correctly, use this Function I wrote to dump the memory at a given location. I would first cache the addresses of each of your variables then at shutdown you could call the DumpVariableMemory passing in references to those locations to see if they have been deallocated.</p> <p>If you don't have one already, you'll need to add a declare fopr CopyMemory too :)</p> <pre><code> Public Function DumpVariableMemory(ByVal lngVariablePointer&amp;, _ ByVal lngBufferSizeInBytes&amp;) As String '' * Object Name: DumpVariableMemory '' * Type: Function '' * Purpose: Returns a memory dump of the variable or pointer location '' * Created: 21/08/2006 - 17:41:32 '' * Coder: Richard Pashley - NUPUK00008148 '' * Build Machine: W-XPRP-77 '' * Encapsulation: Full '' * Parameters: lngVariablePointer - Long - Pointer to the data to dump '' * lngBufferSizeInBytes - Long - Size of the dump to ouput in bytes '' * Returns: - - String - Memory dump output as a string '' * This will dump the memory location starting at the pointer address and '' * ending at the address plus the offset (lngBufferSizeInBytes). '' * You can use LenB to determine the size of the variable for the '' * lngBufferSizeInBytes parameter if required. '' * Example: DebugPrint DumpVariableMemory(VarPtr(lngMyLongValue),LenB(lngMyLongValue) '' * Modified By: [Name] '' * Date: [Date] '' * Reason: [NUPUKxxxxxxxxx] '' Declare locals Dim lngBufferIterator&amp; '' Buffer iterator Dim lngBufferInnerIterator&amp; '' Buffer loop inner iterator Dim bytHexDumpArray() As Byte '' Received output buffer Dim strDumpBuffer$ '' Formatted hex dump construction buffer Dim lngValidatedBufferSize&amp; '' Validated passed buffer size '' Turn on error handling On Error GoTo DumpVariableMemory_Err '' Resize output buffer ReDim bytHexDumpArray(0 To lngBufferSizeInBytes - 1) As Byte '' Retrieve memory contents from supplied pointer Call CopyMemory(bytHexDumpArray(0), _ ByVal lngVariablePointer, _ lngBufferSizeInBytes) '' Format dump header strDumpBuffer = String(81, "=") &amp; vbCrLf &amp; _ "Pointer Address = &amp;h" &amp; Hex$(lngVariablePointer) &amp; _ " Ouput Buffer Size = " &amp; FormatBytes(lngBufferSizeInBytes) '' Add header seperator strDumpBuffer = strDumpBuffer &amp; _ vbCrLf &amp; String(81, Chr$(61)) '' Validate buffer dimensions If lngBufferSizeInBytes Mod 16 = 0 Then '' Validated ok so assign lngValidatedBufferSize = lngBufferSizeInBytes Else '' Refactor to base 16 lngValidatedBufferSize = _ ((lngBufferSizeInBytes \ 16) + 1) * 16 End If '' Iterate through buffer contents For lngBufferIterator = 0 To (lngValidatedBufferSize - 1) '' Determine if first row If (lngBufferIterator Mod 16) = 0 Then '' Format dump output row strDumpBuffer = strDumpBuffer &amp; vbCrLf &amp; Right$(String(8, Chr$(48)) _ &amp; Hex$(lngVariablePointer + lngBufferIterator), 8) &amp; Space(2) &amp; _ Right$(String(4, Chr$(48)) &amp; Hex$(lngBufferIterator), 4) &amp; Space(2) End If '' Determine required dump buffer padding If lngBufferIterator &lt; lngBufferSizeInBytes Then '' Pad dump buffer strDumpBuffer = strDumpBuffer &amp; Right$(Chr$(48) &amp; _ Hex(bytHexDumpArray(lngBufferIterator)), 2) Else '' Pad dump buffer strDumpBuffer = strDumpBuffer &amp; Space(2) End If '' Determine required dump buffer padding If (lngBufferIterator Mod 16) = 15 Then '' Pad dump buffer strDumpBuffer = strDumpBuffer &amp; Space(2) '' Iterate through buffer row For lngBufferInnerIterator = (lngBufferIterator - 15) To lngBufferIterator '' Validate row width If lngBufferInnerIterator &lt; lngBufferSizeInBytes Then '' Validate buffer constraints If bytHexDumpArray(lngBufferInnerIterator) &gt;= 32 And _ bytHexDumpArray(lngBufferInnerIterator) &lt;= 126 Then '' Ouput data to dump buffer row strDumpBuffer = strDumpBuffer &amp; _ Chr$(bytHexDumpArray(lngBufferInnerIterator)) Else '' Pad dump buffer strDumpBuffer = strDumpBuffer &amp; Chr$(45) End If End If Next '' Determine required dump buffer padding ElseIf (lngBufferIterator Mod 8) = 7 Then '' Pad dump buffer strDumpBuffer = strDumpBuffer &amp; Chr$(45) Else '' Pad dump buffer strDumpBuffer = strDumpBuffer &amp; Space(1) End If Next '' Assign result to function output DumpVariableMemory = strDumpBuffer &amp; _ vbCrLf &amp; String(81, Chr$(61)) &amp; vbCrLf Exit_Point: Exit Function '' Error Handling DumpVariableMemory_Err: LogError "modNYFixLibrary.DumpVariableMemory", Err.Number, Err.Description DumpVariableMemory = String(81, Chr$(61)) &amp; vbCrLf &amp; _ "DumpFailed!" &amp; vbCrLf &amp; String(81, Chr$(61)) GoTo Exit_Point Resume End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload