Por que programas alocam tanta memória para comandos simples?

0

Valgrind informa que whois aloca muita memória, mesmo que eu peça sua versão.

$ valgrind whois --version
==18086== Memcheck, a memory error detector
==18086== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==18086== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==18086== Command: whois --version
==18086== 
Version 5.2.11.

Report bugs to <[email protected]>.
==18086== 
==18086== HEAP SUMMARY:
==18086==     in use at exit: 65 bytes in 1 blocks
==18086==   total heap usage: 56 allocs, 55 frees, 15,171 bytes allocated
==18086== 
==18086== LEAK SUMMARY:
==18086==    definitely lost: 0 bytes in 0 blocks
==18086==    indirectly lost: 0 bytes in 0 blocks
==18086==      possibly lost: 0 bytes in 0 blocks
==18086==    still reachable: 65 bytes in 1 blocks
==18086==         suppressed: 0 bytes in 0 blocks
==18086== Rerun with --leak-check=full to see details of leaked memory
==18086== 
==18086== For counts of detected and suppressed errors, rerun with: -v
==18086== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

Experimentando vários outros utilitários, descobri que isso era comum a muitos deles: eles alocavam muita memória para comandos simples. Basta olhar para o gcc!

$ valgrind gcc --version
==18141== Memcheck, a memory error detector
==18141== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==18141== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==18141== Command: gcc --version
==18141== 
gcc (Ubuntu 5.3.1-14ubuntu2.1) 5.3.1 20160413
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

==18141== 
==18141== HEAP SUMMARY:
==18141==     in use at exit: 116,660 bytes in 62 blocks
==18141==   total heap usage: 171 allocs, 109 frees, 135,692 bytes allocated
==18141== 
==18141== LEAK SUMMARY:
==18141==    definitely lost: 4,552 bytes in 13 blocks
==18141==    indirectly lost: 0 bytes in 0 blocks
==18141==      possibly lost: 0 bytes in 0 blocks
==18141==    still reachable: 112,108 bytes in 49 blocks
==18141==         suppressed: 0 bytes in 0 blocks
==18141== Rerun with --leak-check=full to see details of leaked memory
==18141== 
==18141== For counts of detected and suppressed errors, rerun with: -v
==18141== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
    
por EMBLEM 28.06.2016 / 06:58

0 respostas

Tags