Created
September 12, 2018 20:55
-
-
Save jcschefer/d78208e6847d7b8b145b94893576df65 to your computer and use it in GitHub Desktop.
A Sample Tester for List Destructors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <string> | |
| using namespace std; | |
| #include "List.h" | |
| int main () { | |
| List* l; | |
| int n = 0; | |
| while(true) { | |
| l = new List(); | |
| // this is about 3 GB worth of memory on my computer | |
| for (int i = 0; i < 100000000; i++) l-> insertAtTail(2); | |
| cout << "allocating large list for round " << ++n << endl; | |
| // comment out the line below to see what memory leaks would look like | |
| delete l; | |
| cout << "deleted large list for round " << n << endl; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment