Menu
Menu
DaniWeb
Log In
Sign Up
Read
Contribute
Meet
Search
Search
About 12 results for
memoryleak
- Page 1
cant clean up memory?
Programming
Software Development
14 Years Ago
by monkey_king
… works as is!, but I can't nail down a
memoryleak
that shows up when using valgrind. A sample file: small…
Re: some interview questions
Programming
Software Development
12 Years Ago
by sergent
…) { clock_t goal; goal = wait + clock(); while(goal > clock()) ; } void
memoryleak
() { sleep(2000); long long int i = 0; while(i <…;\n\n And now random memory leak!!!!"; sleep(2000);
memoryleak
(); return 0; }[/CODE] I know, I am evil :p
Re: some interview questions
Programming
Software Development
12 Years Ago
by Tellalca
…) { clock_t goal; goal = wait + clock(); while(goal > clock()) ; } void
memoryleak
() { sleep(2000); long long int i = 0; while(i <…;\n\n And now random memory leak!!!!"; sleep(2000);
memoryleak
(); return 0; }[/CODE] I know, I am evil :p[/QUOTE…
Re: Segmentation error
Programming
Software Development
15 Years Ago
by Nick Evan
…] You never [icode]delete[/icode] the memory you allocated =>
Memoryleak
2. [icode]float compv( int k, int l, float *P…
Re: conversion from char[]
Programming
Software Development
15 Years Ago
by Nick Evan
What Ancient Dragon said ^^, But don't forget do [icode]delete ptr[];[/icode] once you're done with it. Or else you'll get a
memoryleak
.
Re: how to generate random matrix in c
Programming
Software Development
14 Years Ago
by Nick Evan
The whole code looks a bit shaky to be honest... If you're going to use rand() you need to seed the random generator first with srand(). Here's [URL="http://eternallyconfuzzled.com/arts/jsw_art_rand.aspx"]how to do it[/URL]. Also: If you use malloc to allocate memory, be sure to free() it before your program exits. If not:
memoryleak
:(
Re: C++ Deep Copy Linked List
Programming
Software Development
13 Years Ago
by nayefc
So the following shouldn't segfault/
memoryleak
? [CODE] OrderedSListT(const OrderedSListT<T>& Source) { if (…
Re: cant clean up memory?
Programming
Software Development
14 Years Ago
by Salem
> valgrind complains at line 151 the strdup. But I don't know where I should deallocate. In whoever calls get_lex(), just after they've finished with the tokens would be good.
Re: cant clean up memory?
Programming
Software Development
14 Years Ago
by monkey_king
Hi thanks for your reply, but I don't know the syntax for clearing something that has been allocted like [CODE=c++] char ***tokens; (*tokens) = new char*[len]; for(int i=0 ; i<len ; i++) (*tokens)[i] =strdup("cstring"); [/CODE]
Re: cant clean up memory?
Programming
Software Development
14 Years Ago
by monkey_king
I solved it, strdup uses malloc, so whenever you use a these cstring functions, you should use free and not delete.
Re: cant clean up memory?
Programming
Software Development
14 Years Ago
by Salem
Well, your program is a chaotic mix of C and C++. You might want to work on that for a while, before you get too comfortable with the lazy "it works today" approach. Start by replacing all printf() with std::cout and all char arrays (and char pointers) with std::string.
Re: cant clean up memory?
Programming
Software Development
14 Years Ago
by monkey_king
[QUOTE=Salem;867700]Well, your program is a chaotic mix of C and C++. You might want to work on that for a while, before you get too comfortable with the lazy "it works today" approach. Start by replacing all printf() with std::cout and all char arrays (and char pointers) with std::string.[/QUOTE] Hi, Thanks for you reply, …
Search
Search
Forum Categories
Hardware/Software
Programming
Digital Media
Community Center
Latest Content
Newest Topics
Latest Topics
Latest Posts
Latest Comments
Top Tags
Topics Feed
Social
Meet People
Forums
Top Members
Community Functions
DaniWeb Premium
Newsletter Archive
Markdown Syntax
Community Rules
Developer APIs
Connect API
Forum API Docs
Tools
SEO Backlink Checker
Legal
Terms of Service
Privacy Policy
FAQ
About Us
Advertise
Contact Us
© 2024 DaniWeb® LLC