| Memory leak in C++ Code - help needed! |
by perpeduumimmobl |
2005-10-06 07:48:23 |
Hoi.
I'm experiencing a quite strange memory leak in a C++ project. I defined a lexicalCast function to get numbers (floats/ints) by strings. valgrind shows a memory leak every time I use the function. 4 bytes, nothing severe, but the code will be reviewed by my prof and valgrind output is mandatory to deliver, so I guess I should fix it... ;-)
Any ideas what's up?
template< typename Type >
Type lexicalCast(const std::string& s) {
std::istringstream* in;
in = new std::istringstream(s);
Type value;
(*in) >> value;
delete in;
return value;
}
|
|
[ Reply ] |
|
memory barf | by onur | 2005-10-06 08:18:13 |
|
Because a lot of us are developers | by ToLazyToThink | 2005-10-06 08:22:20 |
|
Yeah, geez, like chill. :D (n/t) | by williamashbless | 2005-10-06 09:29:24 |
|
What is that? | by Didactylos | 2005-10-06 09:39:41 |
|
it is a book | by onur | 2005-10-06 10:17:22 |
|
Optimal memory usage aside...its probably not that | by williamashbless | 2005-10-06 10:21:48 |
|
I know it's not your fault, | by Didactylos | 2005-10-06 10:42:11 |
|
so then | by onur | 2005-10-06 10:47:29 |
|
It's a valid interpretation. | by wheresthefish | 2005-10-06 10:49:52 |
|
Yes. | by Didactylos | 2005-10-06 10:58:23 |
|
aieee javascript | by onur | 2005-10-06 11:17:01 |
|
I think that his point, while poorly stated, was | by Schol-R-LEA;2 | 2005-10-06 10:34:39 |
|
Hey Onur... couple questions | by threadjacker | 2005-10-06 09:46:20 |
|
hi threadjacker | by onur | 2005-10-06 10:12:00 |
|
w00t! Best advice I've heard today! :D (n/t) | by williamashbless | 2005-10-06 10:15:26 |
|
Is it safe to use istringstream like that? | by ToLazyToThink | 2005-10-06 08:22:41 |
|
nevermind | by ToLazyToThink | 2005-10-06 08:41:13 |
|
Don't forget to destroy | by imrambi | 2005-10-06 08:38:07 |
|
He does, second to last line. (n/t) | by ToLazyToThink | 2005-10-06 08:40:14 |
|
missed it, sorry (n/t) | by imrambi | 2005-10-06 08:41:19 |
|
So what's the '>>' operator doing here? | by wheresthefish | 2005-10-06 08:44:59 |
|
conversion | by onur | 2005-10-06 08:48:25 |
|
That's all very well, | by wheresthefish | 2005-10-06 08:57:34 |
|
well | by onur | 2005-10-06 10:08:39 |
|
Okay, I wrote my own memory use tool. | by williamashbless | 2005-10-06 09:40:53 |
|
(which isn't to say I'm right, but my first stab | by williamashbless | 2005-10-06 09:42:47 |
|
Will the templated | by Didactylos | 2005-10-06 09:48:42 |
|
Return value's on the stack, like any other. | by williamashbless | 2005-10-06 09:53:20 |