Skip to content

Memory leak when using CurlOpt.RESOLVE #677

@Ehsan-U

Description

@Ehsan-U

I was facing a memory leak in long-running spiders. After investigating for about a month, it turned out that only the spiders using CurlOpt.RESOLVE were affected and leak was originating from curl-cffi.

After adding this one line into reset() leak disappeared . I’m not entirely sure if this is the correct or best approach, but it does stop the leak.

curl_cffi/curl.py

def reset(self) -> None:
    self._is_cert_set = False

    lib.curl_slist_free_all(self._resolve)  # Add this line

    if self._curl is not None:
        lib.curl_easy_reset(self._curl)
        self._set_error_buffer()

    self._resolve = ffi.NULL

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions