Comments (3)
The explicit clear()
is necessary, because the vector contains explicit pointers to inner vectors. The delete removes all elements of the outer vector (pointers!), but the inner vector instances need to have their elements removed before the pointer is deleted.
Note that the clear()
call does a double "dereferencing": it
is the iterator, *it
is a pointer and ->
dereferences to the vector<>
.
from nest-simulator.
@terhorstd I don't quite agree with your analysis. We have
std::vector< std::vector< SpikeDataWithRank >* > emitted_spikes_register_;
and
auto it = emitted_spikes_register_.begin();
so *it
gives us the first element of the outer vector, i.e., a pointer to an std::vector<SpikeDataWithRank>
object. The entries in this vector are non-pointer entries, and (*it)->clear()
clears these entries. Afterwards,
delete (*it);
destroys the std::vector<SpikeDataWithRank>
object that *it
points to. In my understanding of C++ containers, deleting a container that contains only non-pointer objects, will properly delete all objects contained in the container, i.e., call their destructors, before deleting the container itself. Therefore, the (*it)->clear()
is superfluous. Afterwards,
emitted_spikes_register_.clear();
removes the now invalid pointers.
from nest-simulator.
After our discussion we concluded that indeed this should also do:
for ( auto vec_spikedata_ptr : emitted_spikes_register_ )
{
delete vec_spikedata_ptr;
}
emitted_spikes_register_.clear(); // remove stale pointers
from nest-simulator.
Related Issues (20)
- aeif-model documentation does not point out peculiarities
- Refactor handling of timers to achieve simpler code in place of use and increase coverage
- NEST hangs when setting connection weight in parallel simulations HOT 2
- Properly control validity of NodeCollections and SynapseCollections with hashes HOT 1
- ConnBuilder loop_over_targets() does not work as intended HOT 1
- NEST behaves incorrectly or fails when connecting sliced layers while using MPI
- Allow use of pairwise_bernoulli rule for connections to devices
- How do you run Potjans_2014 in full scale? HOT 4
- MPI initialization exits ungracefully
- NEST fails to assert presence of required Boost libraries when Boost is configured HOT 2
- Connecting nodes with spatial positions fails in corner case HOT 1
- Nest-simulator 3.4 - installation on MAC - sli HOT 2
- Review use of types for number of processes and threads
- Refactor to use higher mathematical functions available per C++17 HOT 1
- Compiler warns about initializing reference with temporary in astrocyte_lr_1994
- Slow DumpLayerConnections() HOT 4
- Download NEST for working with Python HOT 4
- Displaying NodeCollection is very slow in IPython
- SelectNodesByMask() and DumpLayerConnections() combination problem HOT 1
- Failing MPI tests not properly detected 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 nest-simulator.