Kiểm tra ứng dụng C hay C++

Trong ứng dụng C/C++ lỗi không giải phóng bộ nhớ đã cấp phát rất phổ biến. Có 2 công cụ để kiểm tra lỗi bộ nhớ là:

  1. Valgrind
  2. Dr Memory

Dr Memory được quảng cáo là chạy nhanh hơn , xem chi tiết tại paper này

Cả hai ứng dụng kiểm tra memory đều chạy đa hệ điều hành.

Sử dụng Dr Memory

Có thể chạy Dr Memory bằng dòng lệnh trong cmd prompt

drmemory youApp.exe

Hoặc kéo ứng dụng vào icon shortcut drMemory trên Desktop Kết quả sẽ như sau

Dr. Memory version 1.11.0 build 2 built on Aug 29 2016 02:42:07
Dr. Memory results for pid 4424: "Hex2Bin.exe"
Application cmdline: "Hex2Bin.exe"
Recorded 115 suppression(s) from default C:\Program Files (x86)\Dr. Memory\bin\suppress-default.txt

Error #1: REACHABLE LEAK 8 direct bytes 0x012c0158-0x012c0160 + 0 indirect bytes
<memory was allocated before tool took control>

Error #2: LEAK 255 direct bytes 0x012c0180-0x012c027f + 0 indirect bytes
# 0 replace_malloc               [d:\drmemory_package\common\alloc_replace.c:2576]
# 1 hex2Bin                      [C:/CodeFun/Hex2Bin/main.c:20]
# 2 main                         [C:/CodeFun/Hex2Bin/main.c:11]

===========================================================================
FINAL SUMMARY:

DUPLICATE ERROR COUNTS:

SUPPRESSIONS USED:

ERRORS FOUND:
      0 unique,     0 total unaddressable access(es)
      0 unique,     0 total uninitialized access(es)
      0 unique,     0 total invalid heap argument(s)
      0 unique,     0 total GDI usage error(s)
      0 unique,     0 total handle leak(s)
      0 unique,     0 total warning(s)
      1 unique,     1 total,    255 byte(s) of leak(s)
      0 unique,     0 total,      0 byte(s) of possible leak(s)
      1 unique,     1 total,      8 byte(s) of still-reachable allocation(s)
NO ERRORS IGNORED
Details: C:\Users\cuong\AppData\Roaming\Dr. Memory\DrMemory-Hex2Bin.exe.4424.000\results.txt

results matching ""

    No results matching ""