Comments (5)
I'm not seeing a memory leak here. What is getMemoryUsage
, and what system are you running this on?
My test program (attached) reports that every allocation is paired with a deallocation. (Boost trunk, on Mac OS 10.14)
#include <vector>
#include <iostream>
#include <cstdio>
#include <boost/dynamic_bitset.hpp>
void* operator new (std::size_t count)
{
void *ptr = malloc(count);
::printf ("Allocating %ld bytes at %p\n", count, ptr);
return ptr;
}
void* operator new[]( std::size_t count)
{
void *ptr = malloc(count);
::printf ("Allocating %ld bytes[] at %p\n", count, ptr);
return ptr;
}
void operator delete(void *ptr) throw()
{
::printf ("deleting %p\n", ptr);
free(ptr);
}
void operator delete[](void *ptr) throw()
{
::printf ("deleting[] %p\n", ptr);
free(ptr);
}
int main() {
{
std::vector<boost::dynamic_bitset<>> m_nodes;
// m_nodes.resize(1000000 + 1);
m_nodes.resize(10 + 1);
uint64_t descriptor[4] = {1, 2, 3, 4};
for(size_t i = 0; i < m_nodes.size(); i++)
{
m_nodes[i] = boost::dynamic_bitset<>(descriptor, descriptor + 4);
}
::printf("Exiting scope\n");
}
}
from dynamic_bitset.
Hi, thanks for reply.
- system: ubuntu 18.04, boost 1.66.0 release version, gcc/g++ -7
- getMemoryUsage() is code of get the program memory, it like command "busybox top"
here is the linux code of it:
unsigned long getMemoryUsage()
{
unsigned long MEM = 0;
FILE *f = ::fopen ("/proc/self/stat", "r");
if (!f) return 0;
if (!::fscanf(f,
"%*d %*s %*c %*d %*d %*d %*d %*d%*u %*u %*u %*u %*u %*u %*u%*d %*d %*d %*d %*d %*d %*u %lu", &MEM))
{
// Error parsing:
MEM=0;
}
::fclose (f);
return MEM/1024/1024;
} - For my test program, you can see after destruct of "std::vector<boost::dynamic_bitset<>>", the memory can not restore "13M", that why I mean "std::vector<boost::dynamic_bitset<>>" has memory leak.
from dynamic_bitset.
Hi, I also test std::bitset, the memory of this has not meomory leak, here is the test program
int main()
{
cout << "[ memory start ] " << getMemoryUsage() << std::endl;
{
std::vector<std::bitset <256> > m_nodes;
m_nodes.resize(1000000 + 1);
uint64_t descriptor[4] = {1, 2, 3, 4};
std::bitset <256> tmp(ULONG_MAX);
for(size_t i = 0; i < m_nodes.size(); i++)
{
m_nodes[i] = tmp;
}
}
cout << "[ memory end ] " << getMemoryUsage() << endl;
}
The result is:
[ memory start ] 13
[ memory end ] 13
from dynamic_bitset.
from dynamic_bitset.
Ok, got it, thank you very much.
from dynamic_bitset.
Related Issues (20)
- Valgrind failures in test4 with wchar_t support enabled HOT 4
- Adding hardware supported popcount (and other functions) HOT 2
- Release notes for 1.69.0 HOT 2
- New range based set methods have caused ambiguity HOT 5
- Hardware supported popcount breaks on Windows with CPUs that don't support SSE4 HOT 11
- need to use this as a key in an unordered_map HOT 8
- MSVC hardware-assisted popcount implementation
- Release Notes for 1.70.0 HOT 1
- gcc-4.8 on xenial fails unit test 4 (streaming)
- Coverity flagged issue (investigate) HOT 1
- Release Notes for 1.71.0 HOT 1
- dynamic_bitset cannot be used in a parallel program HOT 3
- boost/dynamic_bitset/dynamic_bitset.hpp:111:20: -Wdeprecated-copy warning
- Release notes for 1.80
- Hide internals (dispatch_init(), init_from_block_range(), m_append())
- Possible improvement for is_proper_subset_of
- It seems that the latest develop branch has 'stdext::hash_value' compile failure
- Make buffer_type changeable
- Missing change in Boost 1.80.0 Unix distributable as opposed to the Windows one
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dynamic_bitset.