//#include <stdlib.h>/*Including used modules for compiling procedure*/#include "Cpu.h"/*Include shared modules, which are used for whole project*/#include "PE_Types.h"#include "PE_Error.h"#include "PE_Const.h"#include "IO_Map.h"uint8* pTest;uint8* pBlock;uint8 x,y,z,a;uint16 pass,fail;void main(void){ /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/ PE_low_level_init(); /*** End of Processor Expert internal initialization. ***/x=0;y=0;pass = 0;fail = 0;//// Here, nothing is already allocated//for(z=1; z<250; z++) { pTest = malloc(z); if(pTest == NULL) ++fail; else { ++pass; free(pTest); } } //Here, every attemp at malloc passedpBlock = malloc(8); //Here, we allocate another block of heappass=0;fail=0; for(z=1; z<250; z++) { pTest = malloc(z); if(pTest == NULL) ++fail; else { ++pass; free(pTest); } } for(;;) {}} //Here, we only had 8 attempts at malloc pass, whith z = 5-12 //The rest of the attempts failed./* END Project */
_MSL_USE_FIX_MALLOC_POOLS For tiny allocations, fixed sized pools help
significantly speed allocation/deallocation, used
only with the modern memory pooling scheme.
You can reserve a pool for a small range of
sizes. The use of fixed sized pools can be
disabled by setting
_MSL_USE_FIX_MALLOC_POOLS to 0. The
default value is 1. Use of fixed size pools
requires further configuration. The current
shipping configuration is:
1. Each pool will handle approximately 4000
bytes worth of requests before asking for more
memory.
2. There are 4 pool types. Each type is
responsible for a different range of requests:
a. 0 - 12 bytes
b. 13 - 20 bytes
c. 21 - 36 bytes
d. 37 - 68 bytes
Requests for greater than 68 bytes go to the
variable size pools. The number of types of pools
is configurable below. The range of requests for
each type is also configurable.
pBlock = malloc(8); //Here, we allocate another block of heapbefore the first 'for' loop. I'm thinking some kind of strange fragmention issue.