unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jess Balint <jbalint@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 22737@debbugs.gnu.org
Subject: bug#22737: 25.1; Finalizer should be optional in dynamic modules
Date: Fri, 26 Feb 2016 10:17:26 -0600	[thread overview]
Message-ID: <CA+fD2U2+tLipoUUw4wNNWm7aGcuq_+S6pJ2Z0bAJbFaSM-da-A@mail.gmail.com> (raw)
In-Reply-To: <83fuwiixnm.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 1660 bytes --]

Situation #1 - globals:

I have pointers to data that are global (not on the heap). I return these
pointers from module functions so that they may be used as parameters to
other module function calls. These pointers should *never* be freed. In
this case I need to supply a no-op finalizer when creating the user pointer.

Situation #2 - manual memory management:

I have heap-allocated structures whose memory should not be managed by
Emacs. I may return pointers to this data one or many times from module
calls. The data should be freed only when explicitly requested. I may
return many user pointers to the same heap-allocated structure. Even when
all these are freed by Emacs, I still retain a pointer in my module which
may be returned in a future module call. Again, I'm required to supply a
no-op finalizer when creating these user pointers.

Thanks.

Jess


On Tue, Feb 23, 2016 at 9:40 PM, Eli Zaretskii <eliz@gnu.org> wrote:

> > Date: Tue, 23 Feb 2016 16:47:12 -0600
> > From: Jess Balint <jbalint@gmail.com>
> > Cc: 22737@debbugs.gnu.org
> >
> > If the data is unspecified it doesn't *necessarily* need to be freed. If
> I return a pointer to some global data then
> > I need to create a no-op finalizer just to please this GC code. In some
> cases I will be managing memory a bit
> > more manually and don't care to have Emacs doing anything for me.
>
> I don't think I follow.  How can you manage memory manually when Emacs
> does GC whenever it feels like it?  The memory of the objects it GCs
> will simply be leaked if you don't have a finalizer.
>
> Can you describe a specific use case where a finalizer would not be
> needed?
>
> Thanks.
>

[-- Attachment #2: Type: text/html, Size: 2279 bytes --]

  reply	other threads:[~2016-02-26 16:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-18 21:52 bug#22737: 25.1; Finalizer should be optional in dynamic modules Jess Balint
2016-02-19  9:33 ` Eli Zaretskii
2016-02-23 22:47   ` Jess Balint
2016-02-24  3:40     ` Eli Zaretskii
2016-02-26 16:17       ` Jess Balint [this message]
2016-02-26 18:36         ` Eli Zaretskii
2016-02-26 18:53           ` Jess Balint
2016-02-26 21:33             ` Eli Zaretskii
2016-02-26 21:51               ` Jess Balint
2016-02-26 21:55                 ` Daniel Colascione
2016-02-29 20:28                   ` Jess Balint

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/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+fD2U2+tLipoUUw4wNNWm7aGcuq_+S6pJ2Z0bAJbFaSM-da-A@mail.gmail.com \
    --to=jbalint@gmail.com \
    --cc=22737@debbugs.gnu.org \
    --cc=eliz@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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).