First post, by tigrou
I have wrote the following C code under Turbo C 3.0:
#include <stdio.h>
#include <alloc.h>
void main()
{
int i;
for (i = 1 ; i < 20 ; i++)
{
unsigned char *p = (unsigned char *)malloc(10000);
if(!p) printf("FAIL %d", i);
}
}
It allocate a block of 10.000 bytes, 20 times.
What I don't understand is why it fails after 6 iterations (when about 60000 bytes have been allocated)
It seems it can't allocate more than 64K in total. I understand that code is running in 16-bit mode so there is limitations but it should work (I should at least be able to allocate about 640K).
What I have tried that does not work :
- change memory model to "compact", "large", "huge"
- add "far" keyword in pointer definition.
- use "farmalloc" instead of "malloc"