FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[MNT]: Is the macosx backend (very slowly) leaking strings? · Issue #21722 · matplotlib/matplotlib · GitHub

Repository navigation

[MNT]: Is the macosx backend (very slowly) leaking strings? #21722

Closed

Description

Summary

macosx.m contains the following snippets:

static PyObject*
FigureManager_set_window_title(FigureManager* self,
                               PyObject *args, PyObject *kwds)
// elided
        NSString* ns_title = [[[NSString alloc]
                               initWithCString: title
                               encoding: NSUTF8StringEncoding] autorelease];
        [window setTitle: ns_title];
// elided

and

static PyObject*
choose_save_file(PyObject* unused, PyObject* args)
// elided
    [panel setTitle: [NSString stringWithCString: title
                                        encoding: NSASCIIStringEncoding]];
    NSString* ns_default_filename =
        [[NSString alloc]
         initWithCString: default_filename
         encoding: NSUTF8StringEncoding];
    [panel setNameFieldStringValue: ns_default_filename];
// elided

I'm don't know anything about autorelease semantics, but it seems a bit worrying that set_window_title makes some GC-related action on ns_title (autorelease) whereas choose_save_file doesn't, just using title and ns_default_filename directly. Or perhaps nothing matters and the autorelease in set_window_title is redundant?

Proposed fix

No response

Activity

  1. QuLogic commented on Nov 23, 2021

    Member

    ns_default_filename is released on the next line, so it's fine. I think title is fine too, as we didn't call alloc explicitly, so it defaults to autorelease, according to https://stackoverflow.com/a/2713941

  2. QuLogic commented on Nov 23, 2021

    Member

    OK, the links from SO were broken, but I think I've found the archived docs which explains it.

    Basically,

    • alloc needs autorelease or release
    • Normal constructor (without alloc) is autorelease

    We should probably just use the default constructor and not bother with explicit release or autorelease.

  3. dstansby commented on Jan 2, 2023

    Member

    Is this fixed by #23060 and/or #23558?

  4. anntzer commented on Jan 2, 2023

    ContributorAuthor

    Hard for me to judge, but at least the offending code isn't there anymore.

  5. QuLogic commented on Jan 4, 2023

    Member

    I think #23060 is likely to have fixed it.

  6. added this to the v3.6.0 milestone on Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL