Инструменты для идентификации пожирателей ресурсов памяти в приложениях VB6

Я ищу слишком долго, и получил решение от моего старшего. в конечном итоге с этим решением. спасибо за вашу помощь

$('.search').on('keyup keydown', function(){
  searchFilter($(this).val());
});

function searchFilter(value){
  $('option').each(function(){
    if($(this).text().toLowerCase().indexOf(value.toLowerCase()) >= 0){
      $(this).removeClass('hidden');
      $(this).removeAttr('disabled');
      
      if($(this).parent().is('span')){
        $(this).unwrap('<span>');
      }
    }else{
      $(this).addClass('hidden');
      $(this).prop('disabled', true);
      
      if(!$(this).parent().is('span')){
        $(this).wrap('<span>');
      }
    }
  });
  $('optgroup').each(function () {
    var qq = $(this).find('span option').length;
    var len = $(this).find('option').length;
    if ($(this).parent().is('span')) {
        $(this).unwrap('<span>');
    }
    if (qq == len) {
        $(this).wrap('<span>');
    }
  });
}
.hidden{
  display: none !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<input type="text" class="search" />

<div class="row">
  <select multiple style="width: 150px;height:200px" id="search">
    <optgroup label="test01">
      <option>car</option>
      <option>bike</option>
      <option>cycle</option>
    </optgroup>
    <optgroup label="test02">
      <option>orange</option>
      <option>apple</option>
      <option>pineapple</option>
    </optgroup>
  </select>
</div>

12
задан madearth 13 April 2009 в 00:03
поделиться

4 ответа

Я не уверен, что какие-либо общедоступные (бесплатные) инструменты профилируют код VB6 до уровня модуля. Есть несколько профилей памяти, доступных для C / C ++ и .NET, но не так много на VB6, который я видел. Похоже, что все старые поставщики (IBM Purify, Compuware Devpartner / Boundschecker) в этой области либо были выкуплены, либо перешли только на поддержку .NET.

Вы можете попробовать GlowCode . В нем говорится о поддержке C ++, но также подчеркивается родной образ x86 для Win32.

Microsoft публикует DebugDiag , который поддерживает обнаружение утечек памяти для .NET или Win32, хотя я никогда не использовал его с VB. Возможно, он не показывает выдающиеся распределения на уровне модуля, но я бы поспорил, что он, по крайней мере, укажет, какие библиотеки / библиотеки распределили больше всего памяти.

2
ответ дан 2 December 2019 в 22:23
поделиться

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.

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.

If you don't have one already, you'll need to add a declare fopr CopyMemory too :)

    Public Function DumpVariableMemory(ByVal lngVariablePointer&, _
                                   ByVal lngBufferSizeInBytes&) 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&                  '' Buffer iterator
    Dim lngBufferInnerIterator&             '' Buffer loop inner iterator
    Dim bytHexDumpArray() As Byte           '' Received output buffer
    Dim strDumpBuffer$                      '' Formatted hex dump construction buffer
    Dim lngValidatedBufferSize&             '' 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, "=") & vbCrLf & _
       "Pointer Address = &h" & Hex$(lngVariablePointer) & _
       "   Ouput Buffer Size = " & FormatBytes(lngBufferSizeInBytes)
    '' Add header seperator
    strDumpBuffer = strDumpBuffer & _
       vbCrLf & 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 & vbCrLf & Right$(String(8, Chr$(48)) _
               & Hex$(lngVariablePointer + lngBufferIterator), 8) & Space(2) & _
               Right$(String(4, Chr$(48)) & Hex$(lngBufferIterator), 4) & Space(2)
        End If
        '' Determine required dump buffer padding
        If lngBufferIterator < lngBufferSizeInBytes Then
            '' Pad dump buffer
            strDumpBuffer = strDumpBuffer & Right$(Chr$(48) & _
               Hex(bytHexDumpArray(lngBufferIterator)), 2)
        Else
            '' Pad dump buffer
            strDumpBuffer = strDumpBuffer & Space(2)
        End If
        '' Determine required dump buffer padding
        If (lngBufferIterator Mod 16) = 15 Then
            '' Pad dump buffer
            strDumpBuffer = strDumpBuffer & Space(2)
            '' Iterate through buffer row
            For lngBufferInnerIterator = (lngBufferIterator - 15) To lngBufferIterator
                '' Validate row width
                If lngBufferInnerIterator < lngBufferSizeInBytes Then
                    '' Validate buffer constraints
                    If bytHexDumpArray(lngBufferInnerIterator) >= 32 And _
                       bytHexDumpArray(lngBufferInnerIterator) <= 126 Then
                        '' Ouput data to dump buffer row
                        strDumpBuffer = strDumpBuffer & _
                           Chr$(bytHexDumpArray(lngBufferInnerIterator))
                    Else
                        '' Pad dump buffer
                        strDumpBuffer = strDumpBuffer & Chr$(45)
                    End If
                End If
            Next
            '' Determine required dump buffer padding
        ElseIf (lngBufferIterator Mod 8) = 7 Then
            '' Pad dump buffer
            strDumpBuffer = strDumpBuffer & Chr$(45)
        Else
            '' Pad dump buffer
            strDumpBuffer = strDumpBuffer & Space(1)
        End If
    Next
    '' Assign result to function output
    DumpVariableMemory = strDumpBuffer & _
       vbCrLf & String(81, Chr$(61)) & vbCrLf
Exit_Point:
    Exit Function
    '' Error Handling
DumpVariableMemory_Err:
    LogError "modNYFixLibrary.DumpVariableMemory", Err.Number, Err.Description
    DumpVariableMemory = String(81, Chr$(61)) & vbCrLf & _
       "DumpFailed!" & vbCrLf & String(81, Chr$(61))
    GoTo Exit_Point
    Resume
End Function
5
ответ дан 2 December 2019 в 22:23
поделиться

На сайте MS есть еще один инструмент под названием processmonitor.exe . Он сообщает о каждом вызове запроса, и вы можете использовать его возможность фильтрации только для отслеживания запросов процесса вашего приложения.

1
ответ дан 2 December 2019 в 22:23
поделиться

Валидатор памяти может сказать вам, где выделяется память (и происходит утечка) в программах VB6 (и C ++, C, Delphi, Fortran 95 ...).

2
ответ дан 2 December 2019 в 22:23
поделиться
Другие вопросы по тегам:

Похожие вопросы: