Question with pointers and free()


 
Thread Tools Search this Thread
Top Forums Programming Question with pointers and free()
# 1  
Old 02-19-2009
Question with pointers and free()

Just a statement I need some clarification

Im aware that malloc() can be used to create pointers, and free() is used to deallocate dynamic memory, however is free() the ONLY way to dispose of the dynamic memory, because not using free() means the dynamic memory still exists and it may cause some issues with your program ?
# 2  
Old 02-19-2009
When you don't free memory that has been allocated before with malloc is termed a memory leak. One major issue with that is if the program keeps asking for dynamic memory without freeing up what it doesn't need then eventually it will run out of heap space. This means that the next request for dynamic memory will not be satisfied and then it all depends on how code handles that exception. Most programs terminate as it's not possible to contine processing.

Last edited by shamrock; 02-19-2009 at 07:37 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Programming

question about Function pointers

Hello forum memebers As iam new to C++ programming i am little bit confuse to understand the function pointers. Please help me to understand the function pointers with examples are suggest me good site for this,Its better if it have picturial representation ie any PPTS available in Google.... (2 Replies)
Discussion started by: rajkumar_g
2 Replies

2. Solaris

MountPoint / is 8% with 899.49MB free crossing threshold of 10% free

Hi, I have a problem one of the server file system cross the limitation MountPoint / is 8% with 899.49MB free crossing threshold of 10% free out put please help how to resolve this dev/vx/dsk/bootdg/rootvol 9.8G 8.8G 956M 91% / /devices ... (3 Replies)
Discussion started by: sriniva0
3 Replies

3. UNIX for Advanced & Expert Users

Free Radius Configuration question

Solaris 10 on an X86 box - Config runs fine has a couple of items in log (really long log file). When I try make I get make: Fatal error in reader: Make.inc, line 84: Unexpected end of line seen line 84 is LIBRADIUS_WITH_OPENSSL = 1 any ideas on what to try? (1 Reply)
Discussion started by: NeedLotsofHelp
1 Replies

4. Programming

Pointer to a struct (with pointers) *** glibc detected *** double free

I am using a structure defined as follows struct gene_square { double *x; double *y; };I have class, with a member function which is a pointer of this type: gene_square* m_Genes;I am allocating memory in the constructors like this: m_Genes = new gene_square; for (ii=0;... (1 Reply)
Discussion started by: jatoo
1 Replies

5. Programming

pointers

Hi I mash with pointers in C. I solve this problem about 5 hours and I don't know how I should continue. void InsertFirst (tList *L, int val) { tElemPtr new; if((new = malloc(sizeof(tElemPtr))) == NULL) Error(); new->data = val; new->ptr = L->frst; L->frst = new;... (2 Replies)
Discussion started by: Milla
2 Replies
Login or Register to Ask a Question