From: Andy Wingo <wingo@pobox.com>
To: ludo@gnu.org (Ludovic Courtès)
Cc: guile-devel@gnu.org
Subject: Re: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-4-g3e05fc0
Date: Tue, 22 Feb 2011 20:11:21 +0100 [thread overview]
Message-ID: <m3vd0bx4ti.fsf@unquote.localdomain> (raw)
In-Reply-To: <87lj18s3l3.fsf@gnu.org> ("Ludovic Courtès"'s message of "Tue, 22 Feb 2011 12:36:56 +0100")
On Tue 22 Feb 2011 12:36, ludo@gnu.org (Ludovic Courtès) writes:
>>>> +
>>>> + if (p->input_cd != (iconv_t) -1)
>>>> + {
>>>> + iconv_close (p->input_cd);
>>>> + p->input_cd = (iconv_t) -1;
>>>> + }
>>>> +
>>>> + if (p->output_cd != (iconv_t) -1)
>>>> + {
>>>> + iconv_close (p->output_cd);
>>>> + p->output_cd = (iconv_t) -1;
>>>> + }
>>>> +
>>>
>>> I don’t think this is needed: each port has a finalizer,
>>> ‘finalize_port’, which normally takes care of this, eventually.
>>
>> It is needed, but only in the case that you `close-port' explicitly.
>> The block in finalize_port only takes care of gc'd open ports.
>
> Right. Closed ports are eventually GC’d, so in that sense it is not
> strictly needed, but OK.
>
> Valgrind was wrong! ;-)
You are setting yourself up for a fall here ;)
When you close a port via "close-port", you remove the port's
SCM_PTAB_ENTRY (port). The SCM_PTAB_ENTRY points to the iconv_t, so the
finalizer would not have a chance to free it, because it can't get to
it. You need to free the iconv_t at the time you remove the link from
the port to the SCM_PTAB_ENTRY -- i.e. at close-port time. Otherwise
you leak the iconv_t.
Trust me: about 500K requests into meta/guile examples/web/hello.scm,
the memory usage was up at about a gigabyte or so :)
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2011-02-22 19:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E1PqVCx-0003xM-4I@vcs-noshell.in.savannah.gnu.org>
2011-02-21 20:50 ` [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-4-g3e05fc0 Ludovic Courtès
2011-02-21 21:19 ` Andy Wingo
2011-02-22 11:36 ` Ludovic Courtès
2011-02-22 19:11 ` Andy Wingo [this message]
2011-02-22 20:35 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3vd0bx4ti.fsf@unquote.localdomain \
--to=wingo@pobox.com \
--cc=guile-devel@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).