Skip to content

possible memory unallocation found #24

Description

@thanhtientc

Hi,

I used the livetext_from_image function in a loop and recognized that my process piled up memory.
Solved it by using NSData.dataWithBytesNoCopy_length_ https://developer.apple.com/documentation/foundation/nsdata/datawithbytesnocopy:length:?language=objc and replacing the Code from Line 210 with this

def imageBytes2nsimage(image_bytes: io.BytesIO):
        ns_data = NSData.dataWithBytesNoCopy_length_(image_bytes.getvalue(), len(image_bytes.getvalue()))
        return NSImage.alloc().initWithData_(ns_data)

    image_bytes = io.BytesIO()
    image.save(image_bytes, format="TIFF")
    ns_image = imageBytes2nsimage(image_bytes)

I do not know how you would cleanly implement and unit test this here, so I thought I would raise an issue.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions