Giter Site home page Giter Site logo

Memory leak on windows about rust-tun HOT 11 OPEN

meh avatar meh commented on August 27, 2024
Memory leak on windows

from rust-tun.

Comments (11)

e1732a364fed avatar e1732a364fed commented on August 27, 2024

代码上怎么写的呢?直接用的 example 吗

from rust-tun.

tubzby avatar tubzby commented on August 27, 2024

@e1732a364fed run the example first, it can read/write to the tun interface, anything other than that should be your own job.

from rust-tun.

e1732a364fed avatar e1732a364fed commented on August 27, 2024

@e1732a364fed run the example first, it can read/write to the tun interface, anything other than that should be your own job.

我是在问,你这个 memory leak 的issue 是由什么代码造成的。你没理解我的意思。比如说,example 的代码是不是就会有你这个 issue 的问题

from rust-tun.

e1732a364fed avatar e1732a364fed commented on August 27, 2024

@e1732a364fed run the example first, it can read/write to the tun interface, anything other than that should be your own job.

为什么理解中文如此难呢?你的截图中有中文

from rust-tun.

tubzby avatar tubzby commented on August 27, 2024

@e1732a364fed run the example first, it can read/write to the tun interface, anything other than that should be your own job.

我是在问,你这个 memory leak 的issue 是由什么代码造成的。你没理解我的意思。比如说,example 的代码是不是就会有你这个 issue 的问题

不是example代码,按照自己的需要加的,我看能不能提供一个能重现问题的mini-example

from rust-tun.

chen2ding avatar chen2ding commented on August 27, 2024

内存泄露,有定位到具体原因吗

from rust-tun.

chen2ding avatar chen2ding commented on August 27, 2024

image
这个地方需要判断cached大小,然后在处理数据(图中直接丢弃),否则程序会崩溃

from rust-tun.

tubzby avatar tubzby commented on August 27, 2024

一直没有处理,我这里不会崩溃,只是内存泄漏。

from rust-tun.

chen2ding avatar chen2ding commented on August 27, 2024

image
把这段删掉就好了,感觉是造成了tokio泄露了

from rust-tun.

tubzby avatar tubzby commented on August 27, 2024

我也感觉这个地方有问题,一直会启动线程。

from rust-tun.

tubzby avatar tubzby commented on August 27, 2024

Got the time to look into this lately, the problem is that Queue::poll_read will fork a new thread if no data is ready, but there might be another thread already polling, which may result in a bunch of threads all stuck in polling, cause a memory leak.

The fix is simple, check if the polling thread is running before creating.

The most important thing is that Queue::poll_read might fired multiple times even if the previous poll_read is in Poll::Pending state.

loop {
  // in this case, Queue::poll_read will fire once no more than 10ms, even if no data is available.
  tokio::select!{
    _ = sleep_10ms() => {},
    msg = dev.next() => {},
  }
}

from rust-tun.

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.