![]() |
|
#1
|
|||
|
|||
Array of Vectors to shared_ptrHi, I want to well define an array of vectors. The vectors contain objects of the type shared_ptr. To be more precise, I have something like this
CPP / C++ / C Code:
To add a shared_ptr to, say, ArrayOfVectorsOfFooPtr[0], I simply do CPP / C++ / C Code:
so the program continues and I am actually able of using it, however, when I delete the array, I always get memory leaks and do know how to bypass this issue. The code I use for deleting it is CPP / C++ / C Code:
Is there anything wrong here? Or maybe the problem is somewhere else? :s |
|||
|
#2
|
|||
|
|||
Re: Array of Vectors to shared_ptrQuote:
Or, did your program statement actually look like the following: CPP / C++ / C Code:
Now, this allocates storage for an array of six vector<FooPtr> objects. Is that what you had? Otherwise, I have to say that other statements in your post don't make much sense to me. (And in fact if that really is your statement and if you used any index value other than zero, the code is invalid.) Now assuming that the real program statement actually created an array, as indicated... As far as memory leaks, I don't think anything that you showed will cause memory leaks. (At least not as reported by valgrind from a program compiled with GNU g++). Quote:
How about making a minimal program that illustrates the leak and show it to us. Be sure to paste the entire exact program into your post. Tell us what compiler you are using and how you are detecting the memory leaks. Regards, Dave |
|
#3
|
|||
|
|||
Re: Array of Vectors to shared_ptrThanks for your answer. Indeed, I just mistyped my code (this is not the actual code but an illustrative simplification of it). I meant
CPP / C++ / C Code:
Later (it is 1 am here) I will provide a more precise piece of the actual code. Thank again for your answer. |
Recent GIDBlog
Install Adobe Flash - Without Administrator Rights by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| where is the problem and can you fix it (php) | oggie | MySQL / PHP Forum | 8 | 14-Apr-2008 15:08 |
| Getting a line error in register | oggie | MySQL / PHP Forum | 5 | 13-Apr-2008 16:16 |
| What is an array? | Howard_L | C Programming Language | 3 | 05-Oct-2007 05:11 |
| How to sort in C++ alphabetically | wilen | C++ Forum | 5 | 20-Apr-2007 14:43 |
| Need help deleting the last element in the array | headphone69 | C++ Forum | 2 | 15-Mar-2006 19:31 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The