- 论坛徽章:
- 0
|
程序结构,主进程不退出,N个子进程,每个子进程处理1000笔交易后,退出,然后主进程获取到子进程退出后,便会再创建一个子进程,进行交易的处理。
- create_child:
- create_child:
- for (iIndex = 0; iIndex < need_chld_nums; iIndex++)
- {
- ....
- fork();
- .....
- }
- ......
- while (wait(NULL) != -1 || errno != ECHILD);
- {
- COMLOG("子进程退出, 重新创建子进程");
- need_chld_nums = 1;
- /*
- km++;
- if (km == 3)
- {
- return 0;
- }
- */
- goto create_child;
- }
复制代码 使用valgrind得出的部分报告内容如下:- valgrind --leak-check=full --log-file=icqz_valgrind --show-reachable=yes
- ==14391== LEAK SUMMARY:
- ==14391== definitely lost: 0 bytes in 0 blocks
- ==14391== indirectly lost: 0 bytes in 0 blocks
- ==14391== possibly lost: 139,648 bytes in 3 blocks
- ==14391== still reachable: 10,895,338 bytes in 31,293 blocks
- ==14391== suppressed: 0 bytes in 0 blocks
- ==14391==
- ==14391== For counts of detected and suppressed errors, rerun with: -v
- ==14391== Use --track-origins=yes to see where uninitialised values come from
- ==14391== ERROR SUMMARY: 1750 errors from 256 contexts (suppressed: 4 from 4)
- ==16751==
- ==16751== HEAP SUMMARY:
- ==16751== in use at exit: 0 bytes in 0 blocks
- ==16751== total heap usage: 10 allocs, 10 frees, 2,584 bytes allocated
- ==16751==
- ==16751== All heap blocks were freed -- no leaks are possible
- ==16751==
- ==16751== For counts of detected and suppressed errors, rerun with: -v
- ==16751== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 4)
复制代码 分4个进程,每个进程发送10000笔交易, 程序处理后,使用top监控,发现内存少了90M,不知道少在哪里了。
|
|