c++ - How to delete a STXXL priority queue? -
i created stxxl priority queue in program. if not need pq more, how delete it? delete[] buffer in c++. want free memory used it.
i looked through their examples , description, cannot find way. once pq created, memory occupied pq until end of program?
for example, if define 2 priority queues: q1 , q2.
typedef stxxl::priority_queue_generator < sufnode<unsigned char>, comparatorgreater<unsigned char>, mem*1024*1024, 1024*1024 >::result pqueue_type0; pqueue_type0 q1(pool1);
then q1, delete it, can allocate more memory q2.
typedef stxxl::priority_queue_generator< sufnode<unsigned char>, comparatorgreater2<unsigned char>, mem*1024*1024, 1024*1024 >::result pqueue_type20; pqueue_type20 q2(pool2);
when q1 goes out of scope, it's memory automatically freed. don't put in 1 big function. put q1 , things in 1 function, , q2 in function.
the biggest problem if q1 needed create q2, , q2 needed create q3, etc. in case, std::unique_ptr<pqueue_type0>
can handy.
Comments
Post a Comment