FUM error

This is a discussion on FUM error within the C Programming forums, part of the General Programming Boards category; Hi All, I am getting some memry leaks in one function. In that function i am allocating memroy for string ...

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    50

    FUM error

    Hi All,

    I am getting some memry leaks in one function. In that function i am allocating memroy for string using calloc and populating that memory with string and using that string om other part of program. Sinc it is showing memory leak, i am trying to release that memory with free function. While i am trying to free the memory, it is showing FUM(free unallocated memory) error. How can i get rid of this error?

    Thanks in advance
    Sas

  2. #2
    cas
    cas is offline
    Registered User
    Join Date
    Sep 2007
    Posts
    993
    Stop trying to free unallocated memory.

    With you not providing any code whatsoever, there's not much more that can be said.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,854
    Which OS are you running? If it's Linux, you should be able to use valgrind to tell you a lot more about how you're mis-using memory.

    p = malloc(10);
    strcpy(p,"hello world");
    free(p);

    Buffer overruns can cause all sorts of difficulty for the memory pool manager, including believing that the block wasn't allocated.

    p = malloc(20);
    strcpy(p,"hello world");
    p = p + 6; // point to world
    free(p);

    Messing about with the start pointer could result in FUM.

    p = malloc(20);
    strcpy(p,"hello world");
    free(p);
    free(p); // oops

    Trying to free the same block twice could result in FUM.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Jan 2010
    Posts
    50
    Quote Originally Posted by Salem View Post
    Which OS are you running? If it's Linux, you should be able to use valgrind to tell you a lot more about how you're mis-using memory.

    p = malloc(10);
    strcpy(p,"hello world");
    free(p);

    Buffer overruns can cause all sorts of difficulty for the memory pool manager, including believing that the block wasn't allocated.

    p = malloc(20);
    strcpy(p,"hello world");
    p = p + 6; // point to world
    free(p);

    Messing about with the start pointer could result in FUM.

    p = malloc(20);
    strcpy(p,"hello world");
    free(p);
    free(p); // oops

    Trying to free the same block twice could result in FUM.
    Thanks for your reply.

    I am running in Linux. I get FUM with purifier.
    Is it posible to get a FUM , that if you allocate memory in one function, and try to free that memory in outside of that function that you allocated?

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    50
    If i try to unallocate, then it would report memory leaks.

  6. #6
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    I think that it would be a good idea to follow cas's inducement and post some code

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,854
    Or you could post the actual text of all your error messages.

    I mean, if you read these things carefully, you should be able to work a few things out to help improve the situation.

    > Is it posible to get a FUM , that if you allocate memory in one function, and try to free that memory in outside of that function that you allocated?
    You mean like how malloc works to begin with - memory is allocated in malloc() and freed in free()
    You're getting FUM because you screwed up using the memory, and nothing to do with where you allocate and free it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 15
    Last Post: 11-28-2011, 11:48 AM
  2. Replies: 4
    Last Post: 07-24-2011, 10:38 PM
  3. Replies: 1
    Last Post: 11-15-2010, 11:14 AM
  4. Replies: 3
    Last Post: 10-02-2007, 10:12 PM
  5. Compiler error error C2065: '_beginthreadex; : undeclared identifier
    By Roaring_Tiger in forum Windows Programming
    Replies: 3
    Last Post: 04-29-2003, 02:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21