---
title: "C++的STL释放内存"
author: "polyahu"
date: "2013-02-24T23:07:59Z"
tags: []
categories: ["编程语言"]
slug: "c-stl"
draft: false
lastmod: "2013-02-24T23:07:59Z"
id: 1814045
url: "https://polyahu.iteye.com/blog/1814045"
---

```C++

vector<int> vec_int;

...;

vec_int.clear();
vector<int>().swap(vec_int);

```



swap这一步必须要啊... 否则内存泄露的一塌糊涂啊... 

这小技巧很值得学习。