curl memory leak 관련 질문입니다.

park3250의 이미지

안녕하세요
SSL, curl 라이브러리 이용하여 개발중인데요

g_easycurl = curl_easy_init();

...

curl_easy_cleanup(g_easycurl);
curl_global_cleanup();

메모리 릭이 발생합니다..

{2915} normal block at 0x00FD2D90, 16 bytes long.
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
{2914} normal block at 0x00FD1888, 20 bytes long.
Data: < - > 00 00 00 00 90 2D FD 00 01 00 00 00 04 00 00 00
e:\my project\consoleapplication20\consoleapplication20\consoleapplication20.cpp(45) : {205} normal block at 0x00FA2058, 4 bytes long.

해당 메모리 번지로 브레이크 포인트 걸어보니..

curl_easy_init()
curl_global_init()
Curl_ssl_init()
Curl_ossl_init()
SSl_library_init()
...
..

위 순서로 함수들이 호출 되는데
SSL 쪽에서 메모리 해제가 되지 않아서 메모리릭이 발생한걸까요?

메모리를 정상적으로 해제할 수 있을까요?
답변 부탁드립니다.

shint의 이미지

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

park3250의 이미지

동작은 되나 메모리릭이 발생되어 질문을 드린겁니다..

익명 사용자의 이미지

http://curl.haxx.se/libcurl/c/curl_easy_init.html

위 링크의 DESCRIPTION 을 보시면 알겠지만,

curl_easy_init의 경우 curl_global_init가 호출되지 않았다면 자기가 스스로 호출한다고 합니다.

그런데 curl_global_init은 Non thread-safe 이기 때문에 멀티 스레드에서 잘못 사용시

치명적인 문제가 발생할 수도 있다고 하네요. 또한 제대로 클린업이 안되서 리소스 문제를 일으킬 수 있다고 합니다.

park3250의 이미지

우선...

단순하게 메모리릭 체크 하기 위해

메인 함수 아래서

curl_easy_init();
curl_easy_cleanup();
curl_global_cleanup();

이렇게만 해도 메모리릭이 발생합니다..

curl_global_init();
curl_easy_init();
curl_easy_cleanup();
curl_global_cleanup();

이렇게도 현상은 동일하구요..

익명 사용자의 이미지

https://github.com/bagder/curl/issues/526

같은 증상인지는 확실하진 않지만 Win7 x64 에서 OpenSSL와 CURL을 사용하다가 메모리 릭을 겪은 사람이 쓴 이슈입니다.

혹시 같은 운영체제, 같은 SSL 라이브러리를 사용하실 경우 참조해보세요.

bushi의 이미지

ini()...cleanup() 을 100여번 반복했을 때 leak 이 증가한다면 버그라 볼 수 있지만, 변함이 없다면 기능이라 볼 수도 있습니다.
피치못할 사유로 백만번쯤 이걸 반복해야하는 프로그램을 만들어야 할 때를 가정하면, 오히려 환영할 일이죠.

almighty의 이미지

제가 사용하는 방법으로는...
7.29, 7.53 에서 memory leak 이 확인되어서...
7.61 로 교체하니 memory leak이 없어졌습니다.
https://curl.haxx.se/changes.html 를 확인해 보시기 바랍니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.