Corrected memory issue using Scott Meyer's "swap trick" to trim excess capacity

This commit is contained in:
Nader Salman 2009-06-02 08:46:23 +00:00
parent 50e4e67739
commit 593a5a8be3
2 changed files with 8 additions and 1 deletions

View File

@ -28,6 +28,9 @@ int main(void)
nb_neighbors,
removed_percentage),
points.end());
// Optional: Scott Meyer's "swap trick" to trim excess capacity
std::vector<Point>(points).swap(points);
return EXIT_SUCCESS;
}

View File

@ -61,7 +61,11 @@ void test_avg_knn_sq_distance(std::deque<Point>& points, // input point set
points.erase(CGAL::remove_outliers(points.begin(), points.end(),
nb_neighbors,
removed_percentage),
points.end());
points.end());
// Optional: Scott Meyer's "swap trick" to trim excess capacity
std::deque<Point>(points).swap(points);
long memory = CGAL::Memory_sizer().virtual_size();
std::cerr << "ok: " << task_timer.time() << " seconds, "