Skip to content
QtWS25 Last Chance
  • 0 Votes
    2 Posts
    188 Views
    M
    @jdent said in Memory Leak in the variables in the UI section of a Qt Widget's application!: Doesn't this constitute a leakage? Read this to find out why not : https://doc.qt.io/qt-6/objecttrees.html
  • Strange memory allocation issues?

    Unsolved General and Desktop memory leak detection test
    4
    0 Votes
    4 Posts
    469 Views
    D
    @Christian-Ehrlicher said in Strange memory allocation issues?: @Dariusz said in Strange memory allocation issues?: Any idea why converting QString to stdString causes memory allocation issues? I don't know what you're trying to achieve - if you want to look for memory leaks use the appropriate tools but those two functions don't leak any memory. /edit: and btw: there is more than one new operator: https://en.cppreference.com/w/cpp/memory/new/operator_new Meh no luck, added other ones but failed to track it :/ // 1. Simple allocation void *operator new(std::size_t size) { if (mRecordData) { allocations++; total++; void *p = std::malloc(size); if (!p) { badAllocs++; totalBadAllocs += size; throw std::bad_alloc(); } totalSizeAllocated += size; return p; } return std::malloc(size); } // 2. Array allocation void *operator new[](std::size_t size) { return ::operator new(size); } // 3. No-exception allocation void *operator new(std::size_t size, const std::nothrow_t &) noexcept { if (mRecordData) { allocations++; total++; void *p = std::malloc(size); if (!p) { badAllocs++; totalBadAllocs += size; } return p; } return std::malloc(size); } // 4. Array no-exception allocation void *operator new[](std::size_t size, const std::nothrow_t &nt) noexcept { return ::operator new(size, nt); } #if __cplusplus >= 201703L // 5. Aligned allocation (C++17 onward) void *operator new(std::size_t size, std::align_val_t al) { if (mRecordData) { allocations++; total++; void *p = _aligned_malloc(static_cast<size_t>(al), size); if (!p) { badAllocs++; totalBadAllocs += size; throw std::bad_alloc(); } totalSizeAllocated += size; return p; } return _aligned_malloc(static_cast<size_t>(al), size); } // 6. Aligned array allocation (C++17 onward) void *operator new[](std::size_t size, std::align_val_t al) { return ::operator new(size, al); } #endif // Corresponding delete overloads void operator delete(void *p) noexcept { if (mRecordData) { deallocations++; total--; } std::free(p); } void operator delete[](void *p) noexcept { ::operator delete(p); } void operator delete(void *p, const std::nothrow_t &) noexcept { ::operator delete(p); } void operator delete[](void *p, const std::nothrow_t &) noexcept { ::operator delete(p); } #if __cplusplus >= 201703L void operator delete(void *p, std::align_val_t) noexcept { ::operator delete(p); } void operator delete[](void *p, std::align_val_t) noexcept { ::operator delete(p); } #endif Bummer! Just wanted a lightweight way of tracking my test allocations/memory footpring :c I know there is valgrind/other ones, but they are harder to set up for per-function tests/etc inside gtest as far as I can tell :/
  • Memory is Leaking but Heob don't get it?

    Solved General and Desktop leak detection heob
    6
    0 Votes
    6 Posts
    624 Views
    S
    @leonardoMB said in Memory is Leaking but Heob don't get it?: Great answer, but what if RAM is a limitation for me? like: I really need that 10 MB If this is really your problem, then you need to provide more information. More specifically we need your platform and operating system (my guess is embedded with a Linux system?). However, you might get better answers for these kind of problems on Stack Overflow as this is not really related to Qt anymore.