LINUX.ORG.RU

История изменений

Исправление fsb4000, (текущая версия) :

still reachable означает что указатель на память не утерян, память может быть теоритически освобождена, но она не освобождена.

Пример:

#include <stdlib.h>

void* a;

int main()
{
   a = malloc(472);
}
valgrind ./a.out 
==16023== Memcheck, a memory error detector
==16023== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==16023== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==16023== Command: ./a.out
==16023== 
==16023== 
==16023== HEAP SUMMARY:
==16023==     in use at exit: 472 bytes in 1 blocks
==16023==   total heap usage: 1 allocs, 0 frees, 472 bytes allocated
==16023== 
==16023== LEAK SUMMARY:
==16023==    definitely lost: 0 bytes in 0 blocks
==16023==    indirectly lost: 0 bytes in 0 blocks
==16023==      possibly lost: 0 bytes in 0 blocks
==16023==    still reachable: 472 bytes in 1 blocks
==16023==         suppressed: 0 bytes in 0 blocks
==16023== Rerun with --leak-check=full to see details of leaked memory
==16023== 
==16023== For lists of detected and suppressed errors, rerun with: -s
==16023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

P.S. это «типа норм» считается, например, PVS-Studio говорили что они только выделяют память, а освобождает сама система, после того как программа завершит анализ файла. Ещё Уолтер Брайт говорил, что в его dmd dlang compiler память только выделяется, а освободится системой, и это одна из фич, которая позволяет компилятору D быстрее собирать код, чем другим компиляторам…

Исходная версия fsb4000, :

still reachable означает что указатель на память не утерян, память может быть теоритически освобождена, но она не освобождена.

Пример:

#include <stdlib.h>

void* a;

int main()
{
   a = malloc(472);
}
valgrind ./a.out 
==16023== Memcheck, a memory error detector
==16023== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==16023== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==16023== Command: ./a.out
==16023== 
==16023== 
==16023== HEAP SUMMARY:
==16023==     in use at exit: 472 bytes in 1 blocks
==16023==   total heap usage: 1 allocs, 0 frees, 472 bytes allocated
==16023== 
==16023== LEAK SUMMARY:
==16023==    definitely lost: 0 bytes in 0 blocks
==16023==    indirectly lost: 0 bytes in 0 blocks
==16023==      possibly lost: 0 bytes in 0 blocks
==16023==    still reachable: 472 bytes in 1 blocks
==16023==         suppressed: 0 bytes in 0 blocks
==16023== Rerun with --leak-check=full to see details of leaked memory
==16023== 
==16023== For lists of detected and suppressed errors, rerun with: -s
==16023== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)