About memory management

classic Classic list List threaded Threaded
5 messages Options
bin
Reply | Threaded
Open this post in threaded view
|

About memory management

bin
I've completed all the JACK system files and passed all the tests, but I still don't know if Memory. jack's memory management is working properly
To be exact, is the memory.deAlloc method playing a role?
how do I test it?

Mark, would you like to have a look at my code?
See if there are any problems.
Reply | Threaded
Open this post in threaded view
|

Re: About memory management

cadet1620
Administrator
The easiest way to test if memory that is deAlloc'ed can be reused is to alloc and deAlloc a large block, then try to alloc many smaller blocks.
let block = Memory.alloc(10000);
do Memory.deAlloc(block);
let i = 10;
while (i > 0) {
	let block = Memory.alloc(1000);
	let i = i-1
}
Since heap is 14K, there will not be enough memory to allocate the ten smaller blocks if the large block was not put back into use.

More challenging is to get this test to run:
let block1 = Memory.alloc(2000);
let block2 = Memory.alloc(2000);
let block3 = Memory.alloc(2000);
let block4 = Memory.alloc(2000);
let block5 = Memory.alloc(2000);
do Memory.deAlloc(block3);      // random order
do Memory.deAlloc(block5);
do Memory.deAlloc(block2);
do Memory.deAlloc(block1);
do Memory.deAlloc(block4);
let block = Memory.alloc(10000);
This requires that contiguous small deAlloc'ed blocks be combined to satisfy the alloc. This process is called defragmentation.
bin
Reply | Threaded
Open this post in threaded view
|

Re: About memory management

bin
ok i got it
i will try it
bin
Reply | Threaded
Open this post in threaded view
|

Re: About memory management

bin
In reply to this post by cadet1620
I passed all the memory tests and it seems that the memory management I wrote is correct.
Reply | Threaded
Open this post in threaded view
|

Re: About memory management

aricamartin
In reply to this post by bin
I am trying to manage the hard disk memory but getting the error code 0x80004005 in my system. I also try on windows error code 0x80004005 for the help purpose but did not get any response.