Skip to content

ZimBlob must keep a reference on the content. #12

Closed

Description

@mgautierfr

Activity

  1. jdcaballerov commented on Apr 21, 2020

    @jdcaballerov
    Contributor

    I added this commit 9068761

    Do you think it's still not enough to avoid gc ?

  2. mgautierfr commented on Apr 21, 2020

    @mgautierfr
    ContributorAuthor

    You added a reference to ZimBlob in the article.
    But you also need to keep a reference to the content itself in the ZimBlob.

  3. jdcaballerov commented on Apr 21, 2020

    @jdcaballerov
    Contributor

    Do you agree ?

    cdef class ZimBlob:
        cdef Blob* c_blob
        cdef object ref_content
        
        def __cinit__(self, content):
    
            if isinstance(content, str):
                self.ref_content = content.encode('UTF-8')
            else:
                self.ref_content = content
    
            self.c_blob = new Blob(<char *> self.ref_content, len(self.ref_content))
    
        def __dealloc__(self):
            if self.c_blob != NULL:
                del self.c_blob

    Or should I retain only the address of that content. If the content is encoded I guess a copy will be made.

  4. mgautierfr commented on Apr 22, 2020

    @mgautierfr
    ContributorAuthor

    Or should I retain only the address of that content. If the content is encoded I guess a copy will be made.

    What need to be done in incrementing the reference on ref_content to be sure that gc will not delete it.
    "Storing" ref_content in self is incrementing the reference. (Without copy, you are making a new reference).

    But it is fix with my commit dee124f of the PR #22
    (The same way of your commit 1133c84 but not merged because on branch cython-blend)

  5. linked a pull request that will close this issueFix multi thread #22on Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions