CPSC 425 Spring 2008
HW 13: Memory Management

  1. Consider the C/C++ function below (syntax may not be exact):
    int test(int x)
    {
      int y;
      int *z;
      
      y = 2;
      z = new int;
      *z = 3;
    
      return x + y + *z;
    }
    
    int main()
    {
      cout << test(1);
    }
    
  2. When during program execution is memory allocated and deallocated for
    1. y?
    2. z?
    3. *z?

  3. Read all of Chapter 14 in Weber. Do exercise 14.1, but you do not need to implement the best-fit version of HeapManager -- just provide the two sequences of operations taht the question asks for (one that works for best fit but not first fit, one vice versa).

  4. The chapter talks about what can happen when memory is improperly deallocated.
    1. Explain the difference between a dangling pointer and a memory leak. Include a description of the error(s) that might be caused by each.
    2. Does garbage collection eliminate both dangling pointers and memory leaks? Explain how or why not.

  5. Read and digest at least one of the primary papers for your programming language. Feel free to use additional sources to assist with your understanding. Then answer the following questions:
    1. What individual(s) and/or organization(s) developed your language, and when?
    2. What motivated the development of your language?
    3. How would you categorize your language? (e.g., functional, object-orientated, etc).
    4. What feature(s) make your language particularly useful and/or different from other languages?