|
-
June 12th, 2009, 05:29 AM
#1
Is this array or vector leaking?
Hi,
I have written an xll (an excel dll) and it leaks like hell. Because of how it's built I have a hard time debuggin it. Could this be leaking?
Code:
double test() {
int dynamicSize = 5;
std::vector<double> v(dynamicSize);
double* r = NULL;
r = new double[dynamicSize];
delete [] r;
v.clear();
}
Thanks.
Last edited by cilu; June 12th, 2009 at 05:39 AM.
Reason: code tags
-
June 12th, 2009, 05:40 AM
#2
Re: What is leaking?
how do u know it's leaking? did u check it against any standard memory leak programs or are you just getting an assertion failure at 'delete'?
-
June 12th, 2009, 05:40 AM
#3
Re: Is this array or vector leaking?
No, there is no leak here.
-
June 12th, 2009, 05:44 AM
#4
Re: What is leaking?
ashwink: When I start Excel and look at how much memory it is using, I see that it leaks.
Cilu: Thank you, that's what I thought. It is something else.
-
June 12th, 2009, 05:56 AM
#5
Re: What is leaking?
Where are you looking for memory usage? Hopefully not in Task Manager, because that can't indicate anything about memory leaks.
-
June 12th, 2009, 07:46 AM
#6
Re: What is leaking?
Yes, I did look at the task manager. If Excel is constantly eating memory when my test xll is running (and not otherwise), then memory must be leaking as far as I know. I think I found the problem though, and now Excel isn't eating memory anymore.
-
June 12th, 2009, 01:13 PM
#7
Re: Is this array or vector leaking?
 Originally Posted by panzram
Could this be leaking?
There are no memory leaks in the code you've posted.
Just in case that this is a pseudo code make sure that in your implementation, test() is not returning or throwing an exception between the memory allocation and the memory release.
Regards
Doron
-
June 12th, 2009, 01:16 PM
#8
Re: What is leaking?
 Originally Posted by panzram
Yes, I did look at the task manager. If Excel is constantly eating memory when my test xll is running (and not otherwise), then memory must be leaking as far as I know. I think I found the problem though, and now Excel isn't eating memory anymore.
OK, but don't rely on Task Manager to identify memory leaks. Use appropriate tools for that.
-
June 12th, 2009, 01:41 PM
#9
Re: What is leaking?
The task manager is only a first indication that there may be a problem. Don't trust it for anything beyond that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|