Thread: free RAM memory

  1. #1
    Registered User
    Join Date
    May 2008

    free RAM memory

    how can we delete char, int, FILETIME?? I delete char from ram like this:

    char* recent = (char*) malloc(256);
    but others??..

    and I have one more questions.. exampla: we have deneme char from asd function(not in main function).. when deneme char cleaned from RAM memory.. while closed function or while closed exe??? sory my english

  2. #2
    Join Date
    Dec 2007
    You only need to free memory allocated on the heap with malloc()/calloc()/alloc() (in C) or new() (in C++). If allocated with malloc()/calloc()/alloc(), then you use free() to free the memory; if allocated with new(), then use delete to free the memory).

    Other variables are created on the stack and will be "freed" when the function in which they're declared goes out of scope.

    Also, do not cast the result of malloc; it is unnecessary and potentially hides important errors. If you need to cast it because you are receiving errors, it is because you are compiling a C program using C++. If you are really using C++, you should be allocating memory with new instead.
    Last edited by rags_to_riches; 05-11-2008 at 07:04 AM. Reason: Grammar

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. tools for finding memory leaks
    By stanlvw in forum C++ Programming
    Replies: 4
    Last Post: 04-03-2009, 11:41 AM
  2. Problems with shared memory shmdt() shmctl()
    By Jcarroll in forum C Programming
    Replies: 1
    Last Post: 03-17-2009, 10:48 PM
  3. Question regarding Memory Leak
    By clegs in forum C++ Programming
    Replies: 29
    Last Post: 12-07-2007, 01:57 AM
  4. Is this code memory leak free? ---> POSIX Threads
    By avalanche333 in forum C++ Programming
    Replies: 9
    Last Post: 04-13-2007, 03:19 PM
  5. Help needed with backtracking
    By sjalesho in forum C Programming
    Replies: 1
    Last Post: 11-09-2003, 06:28 PM