update heap demo
This commit is contained in:
@ -42,8 +42,6 @@ int main() {
|
|||||||
// Initialize scrollback buffer after allocator.init()
|
// Initialize scrollback buffer after allocator.init()
|
||||||
kout.init();
|
kout.init();
|
||||||
|
|
||||||
allocator.dump_free_memory();
|
|
||||||
|
|
||||||
// text_demo();
|
// text_demo();
|
||||||
// sound_demo();
|
// sound_demo();
|
||||||
// keyboard_demo();
|
// keyboard_demo();
|
||||||
|
|||||||
@ -25,17 +25,19 @@ void waitForReturn() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void heap_demo() {
|
void heap_demo() {
|
||||||
|
kout << "HEAP_DEMO ===================================================================" << endl;
|
||||||
|
|
||||||
/* hier muss Code eingefuegt werden */
|
/* hier muss Code eingefuegt werden */
|
||||||
allocator.dump_free_memory();
|
allocator.dump_free_memory();
|
||||||
|
|
||||||
// Some objects and forward/backward merging
|
// Some objects and forward/backward merging
|
||||||
|
kout << "SOME OBJECTS ================================================================" << endl;
|
||||||
MyObj* a = new MyObj(5);
|
MyObj* a = new MyObj(5);
|
||||||
// allocator.dump_free_memory();
|
allocator.dump_free_memory();
|
||||||
MyObj* b = new MyObj(10);
|
MyObj* b = new MyObj(10);
|
||||||
// allocator.dump_free_memory();
|
allocator.dump_free_memory();
|
||||||
MyObj* c = new MyObj(15);
|
MyObj* c = new MyObj(15);
|
||||||
// allocator.dump_free_memory();
|
allocator.dump_free_memory();
|
||||||
delete b;
|
delete b;
|
||||||
allocator.dump_free_memory();
|
allocator.dump_free_memory();
|
||||||
delete a;
|
delete a;
|
||||||
@ -50,8 +52,9 @@ void heap_demo() {
|
|||||||
// allocator.dump_free_memory();
|
// allocator.dump_free_memory();
|
||||||
|
|
||||||
// Allocate too much
|
// Allocate too much
|
||||||
// allocator.alloc(1024 * 1024); // should fail as only 1024 * 1024 - Headersize bytes are available
|
kout << "TOO MUCH ====================================================================" << endl;
|
||||||
// allocator.dump_free_memory();
|
allocator.alloc(1024 * 1024); // should fail as only 1024 * 1024 - Headersize bytes are available
|
||||||
|
allocator.dump_free_memory();
|
||||||
|
|
||||||
// A lot of allocations
|
// A lot of allocations
|
||||||
// MyObj* objs[1024];
|
// MyObj* objs[1024];
|
||||||
@ -66,8 +69,11 @@ void heap_demo() {
|
|||||||
// allocator.dump_free_memory();
|
// allocator.dump_free_memory();
|
||||||
|
|
||||||
// Array allocation
|
// Array allocation
|
||||||
// MyObj* objs = new MyObj[1024];
|
kout << "ARRAY =======================================================================" << endl;
|
||||||
// allocator.dump_free_memory();
|
MyObj* objs = new MyObj[1024];
|
||||||
// delete[] objs;
|
allocator.dump_free_memory();
|
||||||
// allocator.dump_free_memory();
|
delete[] objs;
|
||||||
|
allocator.dump_free_memory();
|
||||||
|
|
||||||
|
kout << "HEAP_DEMO END ===============================================================" << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user