- 论坛徽章:
- 780
|
本帖最后由 Herowinter 于 2014-05-26 17:01 编辑
p [ i ]=new char [ i ];这句,你没有释放p [ i ] 的内存。
回复 7# bjutslg - valgrind --tool=memcheck --leak-check=full --show-reachable=yes --track-origins=yes ./t
- ==7408== Memcheck, a memory error detector
- ==7408== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
- ==7408== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
- ==7408== Command: ./t
- ==7408==
- 7
- ==7408==
- ==7408== HEAP SUMMARY:
- ==7408== in use at exit: 28 bytes in 8 blocks
- ==7408== total heap usage: 9 allocs, 1 frees, 828 bytes allocated
- ==7408==
- ==7408== 28 bytes in 8 blocks are definitely lost in loss record 1 of 1
- ==7408== at 0x4A07152: operator new[](unsigned long) (vg_replace_malloc.c:363)
- ==7408== by 0x4008B0: main (test.cpp:10)
- ==7408==
- ==7408== LEAK SUMMARY:
- ==7408== definitely lost: 28 bytes in 8 blocks
- ==7408== indirectly lost: 0 bytes in 0 blocks
- ==7408== possibly lost: 0 bytes in 0 blocks
- ==7408== still reachable: 0 bytes in 0 blocks
- ==7408== suppressed: 0 bytes in 0 blocks
- ==7408==
- ==7408== For counts of detected and suppressed errors, rerun with: -v
- ==7408== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 6 from 6)
复制代码 |
|