Coder Social home page Coder Social logo

Detected memory leaks! about zeloengine HOT 6 CLOSED

zoloypzuo avatar zoloypzuo commented on May 17, 2024
Detected memory leaks!

from zeloengine.

Comments (6)

zoloypzuo avatar zoloypzuo commented on May 17, 2024

m_config泄露了

从light ud改成ud之后,我期望是lua gc管理,但是泄露了

from zeloengine.

zoloypzuo avatar zoloypzuo commented on May 17, 2024

我觉得问题在于new和delete,这对应构造和析构,必须执行,不只是释放掉本身的内存

所以delete m_pConfig一定要调用的

所以这里要用到lua的__gc来finalize

from zeloengine.

zoloypzuo avatar zoloypzuo commented on May 17, 2024

直接delete也是不对的,会出比较底层的错误,没有任何有意义的错误信息

应该是要重载new和delete的,去学一下怎么搞

from zeloengine.

zoloypzuo avatar zoloypzuo commented on May 17, 2024

https://stackoverflow.com/questions/222557/what-uses-are-there-for-placement-new

这个语法叫做placement new,我们现在的gc的情况就是典型用途之一

问题在于我们应该怎么析构

答案是不需要那么复杂,我们直接调用析构函数即可

m_pConfig->~T();

from zeloengine.

zoloypzuo avatar zoloypzuo commented on May 17, 2024

已解决
image

from zeloengine.

zoloypzuo avatar zoloypzuo commented on May 17, 2024

但是日后应该放到lua __gc中,由lua控制

from zeloengine.

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.