Comments (7)
Code LGTM, probably you are seeing a double-free since I did not disable copies.
If you @disable this(this) and then attempt your test you should see a compilation failure indicating that a copy is not allowed. Can you confirm this?
from dklib.
If you confirm this is the problem I will either disable copies or add copy constructor since that is a relatively new feature in Dlang
from dklib.
Yes disabling copies provides me with a long list of compilation errors.
from dklib.
@charlesgregory can you please provide example code of how you are using nested hashmaps to better understand how we can work around this? I am in favor of disabling copies, but we could potentially instead do refcounting
from dklib.
auto kmers = khash!(string, khash!(string, int))();
for loop {
string kmer1;
string kmer2;
// if kmer1 not present create empty hashmap
// initval is empty hashmap
kmers.require(kmer1, khash!(string, int)()); // <- segfault when kfrees are commented out
// if kmer2 not present make count zero
kmers[kmer1].require(kmer2, 0);
kmers[kmer1][kmer2]++;
}
This could potentially be solved by having special compile time checks for a value type that is another khash instance. Might be difficult.
from dklib.
Yeah you are constructing the object in the parameter position and it is copied into the function.
from dklib.
Changing the ctor function signature value parameter to include auto ref
may fix this although ia m not sure whether should do that or write copy constructor (or both)
from dklib.
Related Issues (2)
- A suggestion HOT 1
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 dklib.