deallocate allocated memory Programming Software Development by atch … what interests me is that in declaration of deallocate in addition to pointer we have also parameter size… of elements allocated with allocate but having implemented my deallocate as this: [code=c++] template<typename T…> void Allocator<T>::deallocate(pointer p, size_type n) { free(p); } [/code]… Deallocate vector memory Programming Software Development by gehring …("stuff"); myarray.push_back(row); myarray.clear(); //Doesnt deallocate the memory myarray.reserve(0); //Doesnt deallocate memory myarray.swap(myarray);//Doesnt… Re: Deallocate vector memory Programming Software Development by Narue [B]>myarray.clear(); //Doesnt deallocate the memory[/B] Correct. Clearing the array only …changes the size. [B]>myarray.reserve(0); //Doesnt deallocate memory[/B] Correct. Reserving space only causes reallocation if the…the current capacity. [B]>myarray.swap(myarray);//Doesnt deallocate memory[/B] This isn't required to shrink-wrap … deallocate contents of std::map Programming Software Development by tomtetlaw Is there any function that allows me to completely remove and [I]deallocate[/I] all contents of a std::map? The functions [icode]clear()[/icode] only removes all elements, it doesn't free any memory. Re: deallocate contents of std::map Programming Software Development by mike_2000_17 … type of storage (sequential container), so calling clear() probably does deallocate all the memory in most implementations. @template<>: I… Exception in deallocate using class vector Programming Software Development by AntonioMG …(); its throw me an exception in xmemory: [code] void deallocate(pointer _Ptr, size_type) { // deallocate object at _Ptr, ignore size ::operator delete(_Ptr… list of pointers; does the default destructor deallocate? Programming Software Development by scotchfx … regmatch_t[ num_subexpressions ]; pm_list.push_back( pm ); will the list destructor automatically deallocate the pointer/array, or will this become a memory leak… Re: list of pointers; does the default destructor deallocate? Programming Software Development by scotchfx Thanks for the response... Would it be considered bad form then to create a list pointers in this manner (as a parameter to a method)... or is it reasonable to expect the next programmer to responsibly deallocate the pointers in the list? Re: list of pointers; does the default destructor deallocate? Programming Software Development by Narue … it reasonable to expect the next programmer to >responsibly deallocate the pointers in the list? Unless they can lazy at… Java Question: Deallocate Temporary arrays of objects? Programming Software Development by Gadgetman_53 … I am done with this tempArray of objects, must I deallocate it somehow, or does garbage collector take care of this… Re: deallocate allocated memory Programming Software Development by Tom Gunn [QUOTE]I have no idea for what I should use this (size_type) parameter.[/QUOTE] If your allocator does not need it, do not worry about it. The allocator interface was designed to be generic, and some allocators will need that information to manage the memory. For example, moving blocks from a 'used' pool to a 'free' pool means knowing how many … Re: deallocate allocated memory Programming Software Development by atch Tom Gunn - Thanks a lot!!! Now I can relax and watch some tv. Once again - thanks Re: Deallocate vector memory Programming Software Development by gehring Hi Narue, Thank you once again. [CODE=C++]vector<vector<CString> >( myarray.begin(), myarray.end() ).swap ( myarray );[/CODE] That works perfectly. Appreciate the help! Re: deallocate contents of std::map Programming Software Development by tomtetlaw It doesn't free any memory as far as I know, is what I meant to say. Re: deallocate contents of std::map Programming Software Development by template<> Rather than put raw pointers, a common technique is to use shared pointers, which use reference counting. Otherwise need to need to iterate and delete your own objects Re: deallocate contents of std::map Programming Software Development by tomtetlaw What I mean is, I have a global map (probably a bad idea) and I want to explicitly free it's used memory so that my memory leak tracker won't report it. It's reporting it because it dumps any unfreed memory at the end of main, but because it's a global map it doesn't get destructed before that. Re: deallocate contents of std::map Programming Software Development by mike_2000_17 I'm pretty sure that swapping with a temporary will solved that problem. PS: You should use a better memory leak tracker, it sounds like yours sucks. Use Valgrind or something similar. Re: deallocate contents of std::map Programming Software Development by Rashakil Fol Real answer: Use valgrind. Another plausible answer: Do something like this: [code] // your global variable, or a thread local variable when appropriate. std::map<key, value> *my_var = NULL; template <class T> class dynamic_bind { T saved_; T *var_; public: dynamic_bind(T *var, const T& value) : saved_(*var), var_(… Re: deallocate contents of std::map Programming Software Development by Rashakil Fol Hello mike_2000_17. Would you mind explaining why that's a dirty hack? That's not dirty at all. It's a proper example of the power of RAII, exception-safe and an excellent tool in general. Global variables (and "dynamic variables," which this construct helps implement) have their place in software and it's better to learn how to deal … Re: deallocate contents of std::map Programming Software Development by mike_2000_17 Ok... This might get a bit out of the scope of this thread, but let's do it anyways: A. Here are some obvious problems with your code: 1) It uses a global variable (ok.. that's not worse than the OP's code). 2) It's a global pointer (which could, obviously point to nowhere). 3) The global pointer is initialized at the start of the main function and… Re: deallocate contents of std::map Programming Software Development by Rashakil Fol I only claim that this idiom is usually very acceptable, and sometimes necessary in some situations, because initialize-on-first-use is unacceptable in some situations, for performance and correctness reasons. These are reasons for which you need to do something at start-up, and not initialize a variable later. At the same time, you need the … Re: deallocate contents of std::map Programming Software Development by vijayan121 [QUOTE]I have a global map (probably a bad idea) and I want to explicitly free it's used memory The functions clear() only removes all elements, it doesn't free any memory. [/QUOTE] Something like this, perhaps: [CODE]template < typename KEY, typename DATA, typename CMP_KEYS = std::less<KEY>, typename ALLOCATOR = std::… Re: deallocate contents of std::map Programming Software Development by mike_2000_17 @Rashakil Fol I think we have a very different point of view on this matter. Probably because of different experiences on different types of software. We might have to agree to disagree. But here is my point of view on some of your comments: [QUOTE=Rashakil Fol;1499467] As for A.3, that's correct (except the last sentence), and irrelevant, since … Re: deallocate contents of std::map Programming Software Development by Rashakil Fol Some of your complaints are based around the practice of having [i]other[/i] global variables that do fancy initialization upon startup. I just avoid these altogether. The initialization of global state is a straightforward process driven by the main function, except for a few standalone hacks. I would want to avoid having a logger with two … Re: How to deallocate memory Programming Software Development by Harshita_garg … asked for.But the problem remains the same. How to deallocate the memory of a temporary variable like C in teh… Deallocate memory at runtime for Dymamic created Controls Programming Software Development by ashishgh I have created an application which creates multiple webbrowser controls at runtime...now i want to clean up memory when these webrowsers are deleted see the code below please let me know how can i do it(i have tried dispose method but no luck) Creation on dynamic web browsers on button click [CODE] Private Sub Button1_Click(ByVal sender As … Re: Deallocate memory at runtime for Dymamic created Controls Programming Software Development by Reverend Jim I came across this piece of code once while trying to solve a similar problem. See if this helps. [code] Private Sub releaseObject(ByVal obj As Object) Try System.Runtime.InteropServices.Marshal.ReleaseComObject(obj) obj = Nothing Catch ex As Exception obj = Nothing Finally GC.Collect() End Try End … Re: Deallocate memory at runtime for Dymamic created Controls Programming Software Development by ashishgh Hi Jim, Thanks for your releaseobject() method...although i was not able to pass the dynamic objects created (TT.wb and TT.pb)under Button1.click method into releaseObject() I have called GC.collect() just as i dispose these dynamic controls and Yippi :icon_cheesygrin: my memory was regained on runtime [CODE] For Each tp As TabPage In … Re: Deallocate memory at runtime for Dymamic created Controls Programming Software Development by Reverend Jim [code] Public Class Form1 Public mytextbox as New TextBox . . . End Class Public Class Form2 . . . MsgBox(Form1.mytextbox.Text) . . . End Class [/code] Re: Deallocate memory at runtime for Dymamic created Controls Programming Software Development by ashishgh Well thats accessing objects accross two classes and thats fine... I want to access some things like below [CODE]Public class something Sub one() Dim TB as New textBox End Sub Sub two() 'How to access TB here ?? or from anywhere in app domain End Sub End class [/CODE]