Skip to content

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

Closed
@anntzer

Description

@anntzer

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions