Giter Site home page Giter Site logo

Comments (4)

smacker avatar smacker commented on May 14, 2024

Hi @sluongng !

The library would call Close automatically when an object becomes unreachable and deallocated by go's garbage collector. To do this we are using runtime.SetFinalizer.

The important line from the documentation:

The finalizer is scheduled to run at some arbitrary time after the program can no longer reach the object to which obj points.

Because cleaning doesn't happen immediately when you process a lot of data you might run out of memory or your program will just consume more memory than desired. For such use cases, we export Close method so that developers have more control and can optimize deallocation.

For most use cases, though, it is not necessary, GC and go runtime will do the job just fine.

Does it answer your question?

from go-tree-sitter.

sluongng avatar sluongng commented on May 14, 2024

Ah thanks, that clarified things quite a lot.

I would suggest providing this information as part of the API doc. 🙏

from go-tree-sitter.

smacker avatar smacker commented on May 14, 2024

Agree. I will be happy to accept a pull request with improved documentation!

from go-tree-sitter.

sluongng avatar sluongng commented on May 14, 2024

Closed with #71

from go-tree-sitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.