Code Monkey home page Code Monkey logo

Comments (4)

greg7mdp avatar greg7mdp commented on August 26, 2024

clear() definitely releases the memory. Depending on the platform you are using (Windows?), you may not notice that the memory has been freed, but it has. For example if, after calling clear(), you create a second hash table with the same elements, the memory usage should not increase.

from sparsepp.

meox avatar meox commented on August 26, 2024

I'm using Linux and Solaris.
The behaviour, respect to memory management, is very similar to std::unordered_map:
seems that the memory is not released to OS after a clear. This is correct in many scenarios but there are some cases that could be usefull to clear and release all the memory back to OS.

from sparsepp.

Bu11etmagnet avatar Bu11etmagnet commented on August 26, 2024

No C++ standard library class or function returns memory "back to the OS". The best C++ classes/methods can do is call delete (which is likely to call free), releasing memory back to the dynamic memory allocator. Whether the dynamic memory allocator releases the memory back to the OS is an implementation detail, not visible from C++.

from sparsepp.

meox avatar meox commented on August 26, 2024

ok thanks for this clarification

from sparsepp.

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.