On (06/04/13 17:22), Youquan Song wrote:
>
> Hello,
> I'd like to ask you to try out the following patch. We leak fd in read_file().
>
No. below patch does not fix the issue. The issue happen at open too
many files at beginning.
Well, the patch is a separate issue not addressing the rlimit problem directly.
We just leak fd in read_file().
-ss
Thanks
-Youquan
>
>
> ------8<--------8<--------
>
> - Do not leak file descriptor in perf_bundle read_file().
> - Clear perf event (unmap memory and close fd) on event destruction.
>
>
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky(a)gmail.com>
>
> ---
>
> diff --git a/src/perf/perf.cpp b/src/perf/perf.cpp
> index 35b4017..e919741 100644
> --- a/src/perf/perf.cpp
> +++ b/src/perf/perf.cpp
> @@ -167,6 +167,7 @@ perf_event::~perf_event(void)
> if (perf_event::pevent->ref_count == 1) {
> pevent_free(perf_event::pevent);
> perf_event::pevent = NULL;
> + clear();
> } else
> pevent_unref(perf_event::pevent);
> }
> diff --git a/src/perf/perf_bundle.cpp b/src/perf/perf_bundle.cpp
> index 38e1e91..8d480e8 100644
> --- a/src/perf/perf_bundle.cpp
> +++ b/src/perf/perf_bundle.cpp
> @@ -123,6 +123,7 @@ static char * read_file(const char *file)
> buffer[len] = '\0';
> }
> out:
> + close(fd);
> return buffer;
> }
>
>