---
title: "C/CPP的fastcgi程序-memleak"
author: "calmhawk"
date: "2012-05-30T09:52:49Z"
tags: []
categories: ["开源软件"]
slug: "c-cpp-fastcgi-memleak"
draft: false
lastmod: "2012-10-15T11:47:09Z"
id: 1544576
url: "https://calmhawk.iteye.com/blog/1544576"
---

原生的用lighttpd起的程序不好检查memory leak.

使用spawn-fcgi调起用valgrind起的fastcgi程序即可.

spawn-fcgi -n -a 127.0.0.1 -p 9000 -- /usr/bin/valgrind --leak-check=full --log-file=/tmp/valgrind.log /path/to/prog

spawn-fcgi -n -a 127.0.0.1 -p 9000 -- /usr/bin/valgrind -v --tool=callgrind --log-file=/tmp/valgrind /path/to/prog

调试的话,直接gdb attach上进程ID即可.