The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

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 onur2005-10-06 08:18:13
    Because a lot of us are developers by ToLazyToThink2005-10-06 08:22:20
      Yeah, geez, like chill. :D (n/t) by williamashbless2005-10-06 09:29:24
    What is that? by Didactylos2005-10-06 09:39:41
      it is a book by onur2005-10-06 10:17:22
        Optimal memory usage aside...its probably not that by williamashbless2005-10-06 10:21:48
        I know it's not your fault, by Didactylos2005-10-06 10:42:11
          so then by onur2005-10-06 10:47:29
            It's a valid interpretation. by wheresthefish2005-10-06 10:49:52
            Yes. by Didactylos2005-10-06 10:58:23
              aieee javascript by onur2005-10-06 11:17:01
      I think that his point, while poorly stated, was by Schol-R-LEA;22005-10-06 10:34:39
    Hey Onur... couple questions by threadjacker2005-10-06 09:46:20
      hi threadjacker by onur2005-10-06 10:12:00
        w00t! Best advice I've heard today! :D (n/t) by williamashbless2005-10-06 10:15:26
  Is it safe to use istringstream like that? by ToLazyToThink2005-10-06 08:22:41
    nevermind by ToLazyToThink2005-10-06 08:41:13
  Don't forget to destroy by imrambi2005-10-06 08:38:07
    He does, second to last line. (n/t) by ToLazyToThink2005-10-06 08:40:14
      missed it, sorry (n/t) by imrambi2005-10-06 08:41:19
  So what's the '>>' operator doing here? by wheresthefish2005-10-06 08:44:59
    conversion by onur2005-10-06 08:48:25
      That's all very well, by wheresthefish2005-10-06 08:57:34
        well by onur2005-10-06 10:08:39
  Okay, I wrote my own memory use tool. by williamashbless2005-10-06 09:40:53
    (which isn't to say I'm right, but my first stab by williamashbless2005-10-06 09:42:47
  Will the templated by Didactylos2005-10-06 09:48:42
    Return value's on the stack, like any other. by williamashbless2005-10-06 09:53:20

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)