473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to release memory occupied by vectors in c++?

Hi

How to release the memory occupied by string vector in c++?

Its very urgent . Pls post your replies?

Thanks in advance
somaskarthic
Sep 9 '06 #1
3 3074
vermarajeev
180 100+
Do you want something like this???

Expand|Select|Wrap|Line Numbers
  1. vector<string> vec;
  2. vec.push_back("Rajeev");
  3. vec.push_back("Verma");
  4. vec.clear();
  5. cout<<vec.size()<<endl;
Update me!!!
Sep 9 '06 #2
Hi

Thanks. We already used vec.clear(). It just clear the value. Not the actual memory occupied by that string vector. ? Can we use delete operator ?
If so , let me know how to use it ?

Pls its very urgent.
somas






Do you want something like this???

Expand|Select|Wrap|Line Numbers
  1. vector<string> vec;
  2. vec.push_back("Rajeev");
  3. vec.push_back("Verma");
  4. vec.clear();
  5. cout<<vec.size()<<endl;
Update me!!!
Sep 9 '06 #3
D_C
293 100+
To trim a vector, swap it with an empty vector. It's one line of code :).
Sep 11 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Birgit Rahm | last post by:
Hello newsgroup, I am a beginner, so I am asking maybe immoderate questions. I want to delete a variable, after filling it with complex objects. How should I do it? e.g. AAA = AAA = Can I...
2
by: anand | last post by:
hi, i am fetching data from database using dataadaptor and filling up a dataset. i checked memory usage of the app, and it consumes 50 Mb of RAM for the given amount of data. that is, i checked...
1
by: trialproduct2004 | last post by:
Hi all, I am having slight confusion regarding memory management in .net. Say suppose i have two application one is in C# and other is in MFC(VC++). Both of this application are using lots...
18
by: Jan | last post by:
Hi there, i've got an STL map with something like this ( map<string, Object*> xyz; ) What happens when I call xyz.clear()? Is only the map cleared or the map and the Objects, so that the memory...
1
by: prashant_sharma | last post by:
Hi, Following code is creating assertion Please help me to release memory occupied by Char array.. char *nm = new char; strcpy(nm,"Prashant"); delete nm; Thanks in Advance
3
by: arne.muller | last post by:
Hello, I've read in the FAQ that modern versions of malloc/free can cache memory, i.e. free does not return memory to the OS so that it may be re-used by the next malloc call. I was thinking...
0
by: somaskarthic | last post by:
Hi I need to get the system memory (not harddisk storage space) occupied by my c++ application ? Is there any readily available methods to find the memory currently occupied by the application ? ...
39
by: Ravi | last post by:
Can you all please suggest a program which tell us the range of memry addresses occupied by the given c program?
1
by: Lambda | last post by:
I'm trying to develop several interesting components of a simple search engine follow some text books. A book introduces some ways to compress dictionary, allow it to stay on main memory. In...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.