[질문]웹서버에 관한 질문.. 제발.. 알려주세요.
저는 벌써 2주쨰 웹서버랑 씨름을 하고 있죠. 해결책이 없더군요..
제발 좀 알려주세요..............................................................
저는 임베디드보드에 웹서버로 boa나 thttpd를
올릴려고 하고 있습니다. 즉, 메모리가 성능에 중요한 영향을 미치죠.
물론, 다 잘 올렸고. 잘 돌아갑니다.
그런데, 문제는 memory leak이 발생한다는 것입니다.
이것의 원인을 밝힐 수가 없습니다.
제가 간단하게 CGI를 만들어서 돌릴때 마다 아주 조금씩
(약4k) 메모리를 잡아먹습니다.
그리고, 아무리 기다려도 메모리는 원상 복귀되지 않습니다.
어떤 분은 웹서버 자체가 메모리 누수가 생기지 않는다고 하시는데,
저는 지금 생기고 있습니다..
boa같은 경우는 select를 이용하고 thttpd는 fork를 이용하는데.
지금 제가 내릴 수 있는 결론은 웹서버에서 leak이 발생한다는 것입니다.
CGI 소스는 정말로 간단합니다..
printf("Content-type: text/html\n\n"); printf("<html>\n"); printf("<body>\n"); printf("test cgi"); printf("</body>\n"); printf("</html>\n");
제발 좀 알려주세요..
이제 저도 좀 쉬고 쉽습니다.
이젠 초점을 웹서버로 돌릴려고 하는데.. 엄두가 나질 않습니다.
혹, 제가 웹서버 설정을 잘못했을 수도 있으니,
혹시, boa나 thttp에 관한 설정도 좀 자세히 알려주시고요.
일단 잘 돌아는 가는 걸로 웹서버 설정 문제는 아닌듯 하지만요..
제발 부탁드립니다.
방금 dmalloc으로 thttp를 수행시키고 CGI를 돌려본 결과입니다.
그리고, 제가 직접 thttp를 kill로 죽인 후의 결과입니다.
자세히 보면 한가지 문제가 있습니다.
근본적으로 서버를 죽이지 않으면 조금씩 메모리 누수가 적용되는거 같습니다.
물론 완전히 서버를 죽이면 모두 프리됩니다.
중간쯤에 보시면 다음과 같은 코드가 나옵니다.
이 부분은 제가 CGI를 수행했을 경우 발생하는 메모리 관련 부분입니다.
그런데 제일 처음 할당된 36bytes는 CGI를 수행하는 시점에 free되지 않고
웹서버를 완전히 kill하는 시점에 죽게 됩니다.
이렇게 되면 임베디드 보드에서는 거의 치명적이게 되는거죠.
이걸 해결할려면 코드를 봐야겠죠..
어떤 부분인지 대충 dmalloc을 아시는 분은 소개 좀 해주세요..
1055763150: 157: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a28c0|s1' 1055763150: 158: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4300|s3' 1055763150: 159: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4200|s3' 1055763150: 160: *** free: at 'ra=0x804d5e7' pnt '0x80c4300|s4': size 201, alloced at 'ra=0x804cfa2' 1055763150: 161: *** free: at 'ra=0x804d5f0' pnt '0x80c4200|s4': size 201, alloced at 'ra=0x804cfa2'
1055763110: 1: Dmalloc version '4.7.1' from 'http://dmalloc.com/'
1055763110: 1: flags = 0xb, logfile 'log'
1055763110: 1: interval = 100, addr = 0, seen # = 0
1055763110: 1: starting time = 1055763110
1055763110: 1: *** alloc: at 'ra=0x4211554b' for 24 bytes, got '0x809e000|s1'
1055763110: 2: *** alloc: at 'ra=0x4208091c' for 15 bytes, got '0x809e020|s1'
1055763110: 3: *** alloc: at 'ra=0x4206bb71' for 364 bytes, got '0x809f000|s1'
1055763110: 4: *** alloc: at 'ra=0x420aa476' for 108 bytes, got '0x80a1000|s1'
1055763110: 5: *** free: at 'ra=0x4206b551' pnt '0x809f000|s2': size 364, alloced at 'ra=0x4206bb71'
1055763110: 6: *** alloc: at 'ra=0x420a91ec' for 12 bytes, got '0x809e040|s1'
1055763110: 7: *** alloc: at 'ra=0x420a91ec' for 12 bytes, got '0x809e060|s1'
1055763110: 8: *** alloc: at 'ra=0x420d31d3' for 60 bytes, got '0x80a2000|s1'
1055763110: 9: *** alloc: at 'ra=0x420d31d3' for 48 bytes, got '0x80a2040|s1'
1055763110: 10: *** free: at 'ra=0x420d3d3e' pnt '0x80a2000|s2': size 60, alloced at 'ra=0x420d31d3'
1055763110: 11: *** free: at 'ra=0x420d3d3e' pnt '0x80a2040|s2': size 48, alloced at 'ra=0x420d31d3'
1055763110: 12: *** alloc: at 'ra=0x420b3b18' for 1024 bytes, got '0x80a3000|s1'
1055763110: 13: *** alloc: at 'ra=0x4206bb71' for 364 bytes, got '0x809f200|s1'
1055763110: 14: *** alloc: at 'ra=0x420f5335' for 8 bytes, got '0x809e080|s1'
1055763110: 15: *** alloc: at 'ra=0x4206c9df' for 120 bytes, got '0x80a1080|s1'
1055763110: 16: *** alloc: at 'ra=0x420f5908' for 15 bytes, got '0x809e0a0|s1'
1055763110: 17: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2080|s1'
1055763110: 18: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a20c0|s1'
1055763110: 19: *** alloc: at 'ra=0x420f5908' for 15 bytes, got '0x809e0c0|s1'
1055763110: 20: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2100|s1'
1055763110: 21: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a2140|s1'
1055763110: 22: *** alloc: at 'ra=0x420f5908' for 14 bytes, got '0x809e0e0|s1'
1055763110: 23: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2180|s1'
1055763110: 24: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a21c0|s1'
1055763110: 25: *** alloc: at 'ra=0x420f5908' for 14 bytes, got '0x809e100|s1'
1055763110: 26: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2200|s1'
1055763110: 27: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a2240|s1'
1055763110: 28: *** alloc: at 'ra=0x420f5495' for 36 bytes, got '0x80a2280|s1'
1055763110: 29: *** alloc: at 'ra=0x420f5908' for 19 bytes, got '0x809e120|s1'
1055763110: 30: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a2000|s3'
1055763110: 31: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2040|s3'
1055763110: 32: *** alloc: at 'ra=0x420f5908' for 15 bytes, got '0x809e140|s1'
1055763110: 33: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a22c0|s1'
1055763110: 34: *** alloc: at 'ra=0x420f5908' for 17 bytes, got '0x809e160|s1'
1055763110: 35: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2300|s1'
1055763110: 36: *** alloc: at 'ra=0x420f5908' for 17 bytes, got '0x809e180|s1'
1055763110: 37: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2340|s1'
1055763110: 38: *** alloc: at 'ra=0x420f5908' for 18 bytes, got '0x809e1a0|s1'
1055763110: 39: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2380|s1'
1055763110: 40: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a23c0|s1'
1055763110: 41: *** alloc: at 'ra=0x420f5908' for 12 bytes, got '0x809e1c0|s1'
1055763110: 42: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2400|s1'
1055763110: 43: *** alloc: at 'ra=0x420f5908' for 17 bytes, got '0x809e1e0|s1'
1055763110: 44: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2440|s1'
1055763110: 45: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a2480|s1'
1055763110: 46: *** alloc: at 'ra=0x420f5908' for 17 bytes, got '0x809e200|s1'
1055763110: 47: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a24c0|s1'
1055763110: 48: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a2500|s1'
1055763110: 49: *** alloc: at 'ra=0x420f5908' for 18 bytes, got '0x809e220|s1'
1055763110: 50: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a2540|s1'
1055763110: 51: *** alloc: at 'ra=0x420f5908' for 18 bytes, got '0x809e240|s1'
1055763110: 52: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2580|s1'
1055763110: 53: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a25c0|s1'
1055763110: 54: *** alloc: at 'ra=0x420f5908' for 16 bytes, got '0x809e260|s1'
1055763110: 55: *** alloc: at 'ra=0x420f5495' for 38 bytes, got '0x80a2600|s1'
1055763110: 56: *** alloc: at 'ra=0x420f5495' for 40 bytes, got '0x80a2640|s1'
1055763110: 57: *** free: at 'ra=0x420f53d8' pnt '0x80a1080|s2': size 120, alloced at 'ra=0x4206c9df'
1055763110: 58: *** free: at 'ra=0x4206b551' pnt '0x809f200|s2': size 364, alloced at 'ra=0x4206bb71'
1055763110: 59: *** alloc: at 'ra=0x420e5aed' for 16 bytes, got '0x809e280|s1'
1055763110: 60: *** alloc: at 'ra=0x420f4d8b' for 8 bytes, got '0x809e2a0|s1'
1055763110: 61: *** alloc: at 'ra=0x420f59cc' for 12 bytes, got '0x809e2c0|s1'
1055763110: 62: *** alloc: at 'ra=0x40006078' for 23 bytes, got '0x809e2e0|s1'
1055763110: 63: *** calloc: at 'ra=0x40008a0c' for 554 bytes, got '0x80a3400|s1'
1055763110: 64: *** alloc: at 'ra=0x40008c2c' for 23 bytes, got '0x809e300|s1'
1055763110: 65: *** alloc: at 'ra=0x4000a3fe' for 28 bytes, got '0x809e320|s1'
1055763110: 66: *** calloc: at 'ra=0x4000c78c' for 128 bytes, got '0x80a1100|s1'
1055763110: 67: *** alloc: at 'ra=0x4206bb71' for 364 bytes, got '0x809f000|s3'
1055763110: 68: *** free: at 'ra=0x4206b551' pnt '0x809f000|s4': size 364, alloced at 'ra=0x4206bb71'
1055763110: 69: *** alloc: at 'ra=0x804c6fa' for 72 bytes, got '0x80a1180|s1'
1055763110: 70: *** alloc: at 'ra=0x4208091c' for 11 bytes, got '0x809e340|s1'
1055763110: 71: *** alloc: at 'ra=0x4208091c' for 1 bytes, got '0x809e360|s1'
1055763110: 72: *** alloc: at 'ra=0x4208091c' for 14 bytes, got '0x809e380|s1'
1055763110: 73: *** alloc: at 'ra=0x4206bb71' for 364 bytes, got '0x809f400|s1'
1055763110: 74: *** free: at 'ra=0x4206b551' pnt '0x809f400|s2': size 364, alloced at 'ra=0x4206bb71'
1055763110: 75: *** alloc: at 'ra=0x4208091c' for 6 bytes, got '0x809e3a0|s1'
1055763110: 76: *** alloc: at 'ra=0x4206bb71' for 364 bytes, got '0x809f600|s1'
1055763110: 77: *** free: at 'ra=0x4206b551' pnt '0x809f600|s2': size 364, alloced at 'ra=0x4206bb71'
1055763110: 78: *** alloc: at 'ra=0x4202b046' for 2272 bytes, got '0x80a4000|s1'
1055763110: 79: *** free: at 'ra=0x4202b076' pnt '0x80a4000|s2': size 2272, alloced at 'ra=0x4202b046'
1055763110: 80: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2680|s1'
1055763110: 81: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a26c0|s1'
1055763110: 82: *** alloc: at 'ra=0x8052ea0' for 4096 bytes, got '0x80a5000|s1'
1055763110: 83: *** alloc: at 'ra=0x8052eb5' for 4096 bytes, got '0x80a6000|s1'
1055763110: 84: *** alloc: at 'ra=0x805306e' for 8192 bytes, got '0x80a7000|s1'
1055763110: 85: *** alloc: at 'ra=0x805307b' for 4096 bytes, got '0x80a9000|s1'
1055763110: 86: *** alloc: at 'ra=0x8053088' for 4096 bytes, got '0x80aa000|s1'
1055763110: 87: *** alloc: at 'thttpd.c:613' for 93288 bytes, got '0x80ab000|s1'
1055763143: 88: *** alloc: at 'thttpd.c:1421' for 464 bytes, got '0x809f000|s5'
1055763143: 89: *** alloc: at 'ra=0x804cfa2' for 501 bytes, got '0x809f200|s3'
1055763143: 90: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2000|s1'
1055763143: 91: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2100|s1'
1055763143: 92: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2200|s1'
1055763143: 93: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2300|s1'
1055763143: 94: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2400|s1'
1055763143: 95: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2500|s1'
1055763143: 96: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2600|s1'
1055763143: 97: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2700|s1'
1055763143: 98: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2800|s1'
1055763143: 99: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2900|s1'
1055763143: 100: checking heap
1055763143: 100: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2a00|s1'
1055763143: 101: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2b00|s1'
1055763143: 102: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2c00|s1'
1055763143: 103: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2700|s1'
1055763143: 104: *** alloc: at 'thttpd.c:1421' for 464 bytes, got '0x809f600|s3'
1055763143: 105: *** alloc: at 'ra=0x804cfa2' for 501 bytes, got '0x809f400|s3'
1055763143: 106: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2d00|s1'
1055763143: 107: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2e00|s1'
1055763143: 108: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c2f00|s1'
1055763143: 109: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4000|s3'
1055763143: 110: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4100|s1'
1055763143: 111: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4200|s1'
1055763143: 112: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4300|s1'
1055763143: 113: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4400|s1'
1055763143: 114: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4500|s1'
1055763143: 115: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4600|s1'
1055763143: 116: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4700|s1'
1055763143: 117: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4800|s1'
1055763143: 118: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4900|s1'
1055763143: 119: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4a00|s1'
1055763143: 120: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4b00|s1'
1055763143: 121: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4c00|s1'
1055763143: 122: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4d00|s1'
1055763143: 123: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4e00|s1'
1055763143: 124: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80a4f00|s1'
1055763143: 125: *** free: at 'ra=0x804d5e7' pnt '0x80a4d00|s2': size 201, alloced at 'ra=0x804cfa2'
1055763143: 126: *** free: at 'ra=0x804d5f0' pnt '0x80a4e00|s2': size 201, alloced at 'ra=0x804cfa2'
1055763143: 127: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2740|s1'
1055763145: 128: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4000|s1'
1055763145: 129: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4100|s1'
1055763145: 130: *** free: at 'ra=0x804d5e7' pnt '0x80c4000|s2': size 201, alloced at 'ra=0x804cfa2'
1055763145: 131: *** free: at 'ra=0x804d5f0' pnt '0x80c4100|s2': size 201, alloced at 'ra=0x804cfa2'
1055763145: 132: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2780|s1'
1055763148: 133: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4200|s1'
1055763148: 134: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4300|s1'
1055763148: 135: *** free: at 'ra=0x804d5e7' pnt '0x80c4200|s2': size 201, alloced at 'ra=0x804cfa2'
1055763148: 136: *** free: at 'ra=0x804d5f0' pnt '0x80c4300|s2': size 201, alloced at 'ra=0x804cfa2'
1055763148: 137: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a27c0|s1'
1055763148: 138: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4400|s1'
1055763148: 139: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4500|s1'
1055763148: 140: *** free: at 'ra=0x804d5e7' pnt '0x80c4400|s2': size 201, alloced at 'ra=0x804cfa2'
1055763148: 141: *** free: at 'ra=0x804d5f0' pnt '0x80c4500|s2': size 201, alloced at 'ra=0x804cfa2'
1055763148: 142: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2800|s1'
1055763149: 143: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4600|s1'
1055763149: 144: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4700|s1'
1055763149: 145: *** free: at 'ra=0x804d5e7' pnt '0x80c4600|s2': size 201, alloced at 'ra=0x804cfa2'
1055763149: 146: *** free: at 'ra=0x804d5f0' pnt '0x80c4700|s2': size 201, alloced at 'ra=0x804cfa2'
1055763149: 147: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2840|s1'
1055763149: 148: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4800|s1'
1055763149: 149: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4900|s1'
1055763149: 150: *** free: at 'ra=0x804d5e7' pnt '0x80c4800|s2': size 201, alloced at 'ra=0x804cfa2'
1055763149: 151: *** free: at 'ra=0x804d5f0' pnt '0x80c4900|s2': size 201, alloced at 'ra=0x804cfa2'
1055763149: 152: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2880|s1'
1055763149: 153: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4100|s3'
1055763149: 154: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4000|s3'
1055763149: 155: *** free: at 'ra=0x804d5e7' pnt '0x80c4100|s4': size 201, alloced at 'ra=0x804cfa2'
1055763149: 156: *** free: at 'ra=0x804d5f0' pnt '0x80c4000|s4': size 201, alloced at 'ra=0x804cfa2'
1055763150: 157: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a28c0|s1'
1055763150: 158: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4300|s3'
1055763150: 159: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4200|s3'
1055763150: 160: *** free: at 'ra=0x804d5e7' pnt '0x80c4300|s4': size 201, alloced at 'ra=0x804cfa2'
1055763150: 161: *** free: at 'ra=0x804d5f0' pnt '0x80c4200|s4': size 201, alloced at 'ra=0x804cfa2'
1055763150: 162: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2900|s1'
1055763150: 163: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4500|s3'
1055763150: 164: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4400|s3'
1055763150: 165: *** free: at 'ra=0x804d5e7' pnt '0x80c4500|s4': size 201, alloced at 'ra=0x804cfa2'
1055763150: 166: *** free: at 'ra=0x804d5f0' pnt '0x80c4400|s4': size 201, alloced at 'ra=0x804cfa2'
1055763150: 167: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2940|s1'
1055763151: 168: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4700|s3'
1055763151: 169: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4600|s3'
1055763151: 170: *** free: at 'ra=0x804d5e7' pnt '0x80c4700|s4': size 201, alloced at 'ra=0x804cfa2'
1055763151: 171: *** free: at 'ra=0x804d5f0' pnt '0x80c4600|s4': size 201, alloced at 'ra=0x804cfa2'
1055763151: 172: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a2980|s1'
1055763151: 173: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4900|s3'
1055763151: 174: *** alloc: at 'ra=0x804cfa2' for 201 bytes, got '0x80c4800|s3'
1055763151: 175: *** free: at 'ra=0x804d5e7' pnt '0x80c4900|s4': size 201, alloced at 'ra=0x804cfa2'
1055763151: 176: *** free: at 'ra=0x804d5f0' pnt '0x80c4800|s4': size 201, alloced at 'ra=0x804cfa2'
1055763151: 177: *** alloc: at 'ra=0x8053ba6' for 36 bytes, got '0x80a29c0|s1'
1055763230: 178: *** free: at 'ra=0x8053f8b' pnt '0x80a2700|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 179: *** free: at 'ra=0x804fd90' pnt '0x809f200|s4': size 501, alloced at 'ra=0x804cfa2'
1055763257: 180: *** free: at 'ra=0x804fd9c' pnt '0x80c2000|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 181: *** free: at 'ra=0x804fda8' pnt '0x80c2100|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 182: *** free: at 'ra=0x804fdb4' pnt '0x80c2200|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 183: *** free: at 'ra=0x804fdc0' pnt '0x80c2300|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 184: *** free: at 'ra=0x804fdcc' pnt '0x80c2400|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 185: *** free: at 'ra=0x804fdd8' pnt '0x80c2500|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 186: *** free: at 'ra=0x804fde4' pnt '0x80c2600|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 187: *** free: at 'ra=0x804fdf0' pnt '0x80c2700|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 188: *** free: at 'ra=0x804fdfc' pnt '0x80c2800|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 189: *** free: at 'ra=0x804fe08' pnt '0x80c2900|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 190: *** free: at 'ra=0x804fe14' pnt '0x80c2a00|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 191: *** free: at 'ra=0x804fe20' pnt '0x80c2b00|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 192: *** free: at 'ra=0x804fe2c' pnt '0x80c2c00|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 193: *** free: at 'thttpd.c:1366' pnt '0x809f000|s6': size 464, alloced at 'thttpd.c:1421'
1055763257: 194: *** free: at 'ra=0x804fd90' pnt '0x809f400|s4': size 501, alloced at 'ra=0x804cfa2'
1055763257: 195: *** free: at 'ra=0x804fd9c' pnt '0x80c2d00|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 196: *** free: at 'ra=0x804fda8' pnt '0x80c2e00|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 197: *** free: at 'ra=0x804fdb4' pnt '0x80c2f00|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 198: *** free: at 'ra=0x804fdc0' pnt '0x80a4000|s4': size 201, alloced at 'ra=0x804cfa2'
1055763257: 199: *** free: at 'ra=0x804fdcc' pnt '0x80a4100|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 200: checking heap
1055763257: 200: *** free: at 'ra=0x804fdd8' pnt '0x80a4200|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 201: *** free: at 'ra=0x804fde4' pnt '0x80a4300|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 202: *** free: at 'ra=0x804fdf0' pnt '0x80a4400|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 203: *** free: at 'ra=0x804fdfc' pnt '0x80a4500|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 204: *** free: at 'ra=0x804fe08' pnt '0x80a4600|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 205: *** free: at 'ra=0x804fe14' pnt '0x80a4700|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 206: *** free: at 'ra=0x804fe20' pnt '0x80a4800|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 207: *** free: at 'ra=0x804fe2c' pnt '0x80a4900|s2': size 201, alloced at 'ra=0x804cfa2'
1055763257: 208: *** free: at 'thttpd.c:1366' pnt '0x809f600|s4': size 464, alloced at 'thttpd.c:1421'
1055763257: 209: *** free: at 'ra=0x804c66e' pnt '0x809e380|s2': size 14, alloced at 'ra=0x4208091c'
1055763257: 210: *** free: at 'ra=0x804c694' pnt '0x809e340|s2': size 11, alloced at 'ra=0x4208091c'
1055763257: 211: *** free: at 'ra=0x804c6a7' pnt '0x809e360|s2': size 1, alloced at 'ra=0x4208091c'
1055763257: 212: *** free: at 'ra=0x804b820' pnt '0x80a1180|s2': size 72, alloced at 'ra=0x804c6fa'
1055763257: 213: *** free: at 'ra=0x8053f8b' pnt '0x80a29c0|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 214: *** free: at 'ra=0x8053f8b' pnt '0x80a2980|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 215: *** free: at 'ra=0x8053f8b' pnt '0x80a26c0|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 216: *** free: at 'ra=0x8053f8b' pnt '0x80a28c0|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 217: *** free: at 'ra=0x8053f8b' pnt '0x80a2840|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 218: *** free: at 'ra=0x8053f8b' pnt '0x80a2900|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 219: *** free: at 'ra=0x8053f8b' pnt '0x80a2780|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 220: *** free: at 'ra=0x8053f8b' pnt '0x80a2800|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 221: *** free: at 'ra=0x8053f8b' pnt '0x80a27c0|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 222: *** free: at 'ra=0x8053f8b' pnt '0x80a2940|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 223: *** free: at 'ra=0x8053f8b' pnt '0x80a2680|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 224: *** free: at 'ra=0x8053f8b' pnt '0x80a2740|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 225: *** free: at 'ra=0x8053f8b' pnt '0x80a2880|s2': size 36, alloced at 'ra=0x8053ba6'
1055763257: 226: *** free: at 'thttpd.c:1383' pnt '0x80ab000|s2': size 93288, alloced at 'thttpd.c:613'
1055763257: 227: WARNING: tried to free(0) from 'ra=0x400323fe'
1055763257: 227: free: invalid pointer: from 'ra=0x400323fe'
1055763257: 227: ERROR: _chunk_free: pointer is null (err 20)
1055763257: 228: *** free: at 'ra=0x4211581d' pnt '0x809e000|s2': size 24, alloced at 'ra=0x4211554b'
1055763257: 228: free bucket count/bits: 102/5 38/6 30/7 44/8 8/9 2/10 1/17
1055763257: 228: dumping chunk statistics
1055763257: 228: basic-block 4096 bytes, alignment 8 bytes, heap grows up
1055763257: 228: heap: 0x809c000 to 0x80c5000, size 167936 bytes (41 blocks)
1055763257: 228: heap checked 2
1055763257: 228: alloc calls: malloc 144, calloc 2, realloc 0, free 82
1055763257: 228: alloc calls: recalloc 0, memalign 0, valloc 0
1055763257: 228: total memory allocated: 138419 bytes (146 pnts)
1055763257: 228: max in use at one time: 130043 bytes (116 pnts)
1055763257: 228: max alloced with 1 call: 93288 bytes
1055763257: 228: max alloc rounding loss: 4869 bytes (3%)
1055763257: 228: max memory space wasted: 14847 bytes (9%)
1055763257: 228: final user memory space: basic 29, divided 8, 149759 bytes
1055763257: 228: final admin overhead: basic 1, divided 3, 16384 bytes (9%)
1055763257: 228: final external space: 0 bytes (0 blocks)
1055763257: 228: top 10 allocations:
1055763257: 228: total-size count in-use-size count source
1055763257: 228: 93288 1 0 0 thttpd.c:613
1055763257: 228: 11454 54 804 4 ra=0x804cfa2
1055763257: 228: 8192 1 8192 1 ra=0x805306e
1055763257: 228: 4096 1 4096 1 ra=0x8053088
1055763257: 228: 4096 1 4096 1 ra=0x8052ea0
1055763257: 228: 4096 1 4096 1 ra=0x805307b
1055763257: 228: 4096 1 4096 1 ra=0x8052eb5
1055763257: 228: 2272 1 0 0 ra=0x4202b046
1055763257: 228: 1820 5 0 0 ra=0x4206bb71
1055763257: 228: 138419 146 28607 65 Total of 30
1055763257: 228: dumping not-freed pointers changed since 0:
1055763257: 228: memory table is empty
1055763257: 228: unknown memory: 65 pointers, 28607 bytes
1055763257: 228: ending time = 1055763257, elapsed since start = 0:02:27
[/code]
전에 제가 사용했던 방법인데,,, 메모리 leak 이라면, all
전에 제가 사용했던 방법인데,,,
메모리 leak 이라면, alloc 하고 free 를 안해서 이겠지요...
alloc 하는 부분의 포인터를 출력하실 수 있다면,
free 하는 부분의 포인터를 출력하실 수 있을것 같은데요..
CGI 를 한번 구동할때마다, 출력을 하도록 한다음에,
포인터의 값들을 비교해 보면,
free 가 안되는 포인터를 찾을수 있습니다.
양이 많다고 해도, 요즘은 좋은 에디터가 많이 나와있으니깐,
불러들여서 find 를 이용해서 하나씩 마크해 나가시기 바랍니다.
그럼, 참고하시기 바랍니다.
thttpd는 한번 할당된 메모리(커넥션은 다르지만 출력을 위한 버퍼)는
thttpd는 한번 할당된 메모리(커넥션은 다르지만 출력을 위한 버퍼)는 웬만해서는 내리지 않습니다. 대신 주기적으로 mmc_cleanup()이라는 함수를 불러서 정해진 규칙에 따라(크기와 레퍼런스 카운트 등) 안쓰는 메모리는 청소하도록 되어 있습니다. 그래서 leak처럼 보이는 것일 지도 모르겠네요.
메모리 할당 관련은 thttpd의 mmc.c에 모아져 있습니다.
--
익스펙토 페트로눔
답변감사합니다. 정해진 규칙이라면..
thttp에서 정해진 규칙에 따라 메모리를 free한다고 하셨는데요..
그 정해진 규칙을 어떻게 하면 설정이 가능한가요?
예를 들어 몇초 단위로 메모리를 해제한다든가?
이런 방식인거 같은데..
실력이 있으면 삶이 편하다... 영차 영차...
boa를 이용하여 테스트 한 결과..
boa도 메모리 누수가 발생합니다.
그런데, 이상한 것은 일반 PC에서 dmalloc으로 찍어본 결과
정확히 누수가 없습니다.
그런데, 임베디드 보드에만 올리면 웹페이지를 로드하는 시점 부터
메모리를 조금씩 갈가먹습니다..
도대체 무엇이 문제인지 모르겠습니다.
내일.. 보드를 바꿔서 테스트 할 예정입니다..
지금까지 테스트한 결과를 말씀드리죠.. 자세히 읽어보시고.
무엇이 문제인지 알려주세요..
먼저, THTTP web server
일반 PC
dmalloc으로 측정한 결과 memory free time에서 정책적으로
조금씩 할당하여 누수가 발생하는 듯하지만, 웹서버를 죽일 경우 모두 free가 됨.
임베디드 보드
arm-uclibc-gcc 툴체인으로 컴파일한 후에 보드에 올리고 테스트를
한 결과 메모리를 조금씩 갈가먹음..
다음으로 boa web server
일반 PC
dmalloc으로 측정한 결과 메모리 누수가 발생하지 않음.
정확히 말씀드리면 제가 단순한 CGI를 수행하면 메모리를 할당하고 다시
이를 전부 해제함.
임베디드 보드
arm-uclibc-gcc 툴체인으로 컴파일한 후에 보드에 올리고 테스트를
한 결과 메모리를 조금씩 갈가먹음..
실력이 있으면 삶이 편하다... 영차 영차...
댓글 달기