Memory leak

Issue #26 resolved
Former user created an issue

First, thanks for your perfect works. I got a issue when writing BLF file.I will write 1000 can frames every 40ms, and i saw the memory of my software is increasing slowly, even i write 100 can frames it also increasing.I'm looking for the reason too.

Comments (9)

  1. Tobias Lorenz repo owner

    Hello Zheng,

    the code looks ok. You can make some things simpler:

    • On construction of CanMessage and CanFdMessage the following variables are already set: objectType, objectVersion. So you can delete these lines.
    • On writing of CanMessage and CanFdMessage the following variables are set automatically: headerSize, objectSize. So you can delete these lines.
    • Objects can either be constructed with “new” (as done with CanMessage”) or with “createObject” (as done with CanFdMessage). I propose to use “new” also for CanFdMessage, as that’s simpler and faster.

    Now to the memory leak: It might be that the sizeof() call causes the memory leak. As mentioned it’s auto calculated, so can just delete these lines. Can you test, if the memory leak is gone then?

    Part of my tests is also to run vagrant leak checker. And in the last version it didn’t showed any issues… I’ll wait for your feedback before proceeding with further tests.

    Bye

    Tobias

  2. Creed Zheng

    I’m sorry to say, it not work. As you said i modified my code as below

    I had added print in readWriteQueue2UncompressedFile function, before delete. And the objects is really deleted.

  3. Creed Zheng

    I write an other test code, just new a can message then delete it without write function, memory is also increasing.

  4. Tobias Lorenz repo owner

    Hi Creed,

    I’m glad to hear that. So you found the bug and fixed it. That’s all that counts 😉

    Bye

    Tobias

  5. Log in to comment