GSP 215 Week 6 iLab Week 6 Lab”�Virtual Memory TCO 9″�Given the need to support the runtime creation of varying quantities of data objects, learn how dynamic memory allocation can provide this capability in a very efficient way. TCO 8″�Given the need to understand virtual memory, describe how memory allocation and paging are used to give a computer program access to more memory than physically available. Scenario In this week’s lab, you will override the new and delete operators for an implementation of linked list. Rubric Point distribution for this activity Lab Activity Document � Points possible � � Points received Code and screenshot 40 � Total Points 40 � Generally, the default implementation of new and delete is sufficient for a given program. At times, you may want to specialize memory allocation for advanced tasks. You may want to allocate instances of a certain class from a particular memory pool, implement your own garbage collector, or caching. We will override the new and delete operator in this lab. When overriding these operators, both need to be overridden. The new operator allocates memory and creates an object. The delete operator deallocates memory. We will be implementing a linked list class and overloading the new and delete operator. We can improve the speed of allocating new nodes by keeping a list of deleted nodes and reusing the memory when new nodes are allocated. The code for the linked list is below. You may also use your own implementation of linked list. The overloaded new operator will check a freelist to recycle a node before going to the heap and getting one that way. The delete operator will add the node to the freelist. Hint: Use the following in the Node class. void * operator new(size_t); void operator delete(void*); static void printFreelist(); After the class Node definition, be sure to set the freelist to NULL. Node* Node::freelist=NULL; Implement Node::printFreelist() as well, and in the Main, include calls to Node::printFreelist(); to see the nodes in the free list. Original C++ Code: #include
Previous answers to this question
This is a preview of an assignment submitted on our website by a student. If you need help with this question or any assignment help, click on the order button below and get started. We guarantee authentic, quality, 100% plagiarism free work or your money back.
Get The Answer