Giter Club home page Giter Club logo

dekit's People

Stargazers

 avatar

Watchers

 avatar  avatar

dekit's Issues

Memory leak with DirectoryEvents class

Description

I want a clear API for my class so I've marked initializer with @discardableResult if I only need to watch one directory for events. Only on the next morning (Yes, I've coded this at night ๐Ÿ˜…) I've realized that this code can only work if there a retain cycle. So I've try to dig into memory graph, but I don't find any retain cycles, only kevents pointing to my class.

Screen Shot 2020-05-13 at 01 32 14

Screen Shot 2020-05-13 at 01 32 28

It's strange because they should disappear as soon as all directory files is no longer watched - but they don't. Main problem that I see here is that all watched files possibly will never be closed (because classes deinit is never called) and it's definitely not good for memory usage.

deinit {
    close(kernelQueue)
    closeWatched()
}

private func closeWatched() {
    // keys here is files descriptors 
    watchedFiles.keys.forEach { closeFile($0) }
    close(watchedDirectory)    
}

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.