Help needed in Memory Management in C++
-
I encountered a problem in c++ while allocating memory more than 64KB in DOS throughTurbo C++ compiler. For some program in needed 1MB of memory. There wasn't any error for not much memory but still i could get a maximum of 60KB. Can anybody help in the problem
ramachandran m s
-
I encountered a problem in c++ while allocating memory more than 64KB in DOS throughTurbo C++ compiler. For some program in needed 1MB of memory. There wasn't any error for not much memory but still i could get a maximum of 60KB. Can anybody help in the problem
ramachandran m s
For a 16-bit program, the largest block of memory you can allocate is 65536 bytes (minus 16 bytes, if I remember correctly, since it may not return a pointer on a page boundary). You'll need to either allocate a number of blocks less than 64KB and index through them, or use a compiler capable of producing 32-bit executables (is there a specific reason you're using Turbo C++ for DOS?) - Mike
-
For a 16-bit program, the largest block of memory you can allocate is 65536 bytes (minus 16 bytes, if I remember correctly, since it may not return a pointer on a page boundary). You'll need to either allocate a number of blocks less than 64KB and index through them, or use a compiler capable of producing 32-bit executables (is there a specific reason you're using Turbo C++ for DOS?) - Mike
:rose::-O
Thanks for ur information mike. is there any 32 bit compilers in dos. the specific reason i am using turbo c++ is i want to get rid of that windows dlls. i want my program to run seperately without any external support. if there any possibilities plz return back to me.
ramachandran m s
-
:rose::-O
Thanks for ur information mike. is there any 32 bit compilers in dos. the specific reason i am using turbo c++ is i want to get rid of that windows dlls. i want my program to run seperately without any external support. if there any possibilities plz return back to me.
ramachandran m s
Try DJGPP: http://www.delorie.com/djgpp/[^] - Mike
-
Try DJGPP: http://www.delorie.com/djgpp/[^] - Mike
i feel its a little bit bitter to work in a command line compiler. is there any other compilers like tc which has inbuilt editor & debugging facilities & that works well in DOS
ramachandran m s
-
I encountered a problem in c++ while allocating memory more than 64KB in DOS throughTurbo C++ compiler. For some program in needed 1MB of memory. There wasn't any error for not much memory but still i could get a maximum of 60KB. Can anybody help in the problem
ramachandran m s
In the TC IDE, take Options->Compiler-> Code Generation and in the "Model" group, change selection to "Huge". Now you can allocate memory more than 64Kb. :) Isn't it simple ? ;) Regards, Jijo ________________________________ Yesterday is history, Tomorrow is a mystery, But today is a present.
-
In the TC IDE, take Options->Compiler-> Code Generation and in the "Model" group, change selection to "Huge". Now you can allocate memory more than 64Kb. :) Isn't it simple ? ;) Regards, Jijo ________________________________ Yesterday is history, Tomorrow is a mystery, But today is a present.
:rose:tks for the immediate responce. :confused: i've tried this earlier. but since if i request for more than 64KB through malloc() it is allocating a maximum of 63KB. is there any solution for this problem or any other function or lib can solve this problem. :-O plz respond to me if there any.
ramachandran m s
-
:rose:tks for the immediate responce. :confused: i've tried this earlier. but since if i request for more than 64KB through malloc() it is allocating a maximum of 63KB. is there any solution for this problem or any other function or lib can solve this problem. :-O plz respond to me if there any.
ramachandran m s
Dear ramachandran, The problem is simple. Please use farmalloc () function in the alloc.h. This function can allocate memory more than 64KB. Then the only condition for the function is that the model should be greater than tiny. I hope this will solve your problem. Simple, isn't it ? ;) Regards, Jijo. ________________________________ Yesterday is history, Tomorrow is a mystery, But today is a present.
-
Dear ramachandran, The problem is simple. Please use farmalloc () function in the alloc.h. This function can allocate memory more than 64KB. Then the only condition for the function is that the model should be greater than tiny. I hope this will solve your problem. Simple, isn't it ? ;) Regards, Jijo. ________________________________ Yesterday is history, Tomorrow is a mystery, But today is a present.
:rose:Tks Jijo, i think this will solve my problem. but i can't understand the systax of this function. i am getting some error message or the system hangs while using this function. can u send me any example programs demonstrating this.
:-O kind regards from, ramachandran m s
-
:rose:Tks Jijo, i think this will solve my problem. but i can't understand the systax of this function. i am getting some error message or the system hangs while using this function. can u send me any example programs demonstrating this.
:-O kind regards from, ramachandran m s
first include the header file alloc.h
#include alloc.h
Eg: if you want to allocate a char array using farmalloc (),
char far* ptr; ptr = (char far*) farmalloc ( size );
now do the required operations. The only difference is that we used a far pointer it behaves just like an ordinary pointer but, ordinary pointers like char* can only handle 64KB of memory locations, but this far pointer can handle memory of more than 64KB. Take care to free the allocated memory using farfree().
farfree ( ptr );
hope now all the problem solves. If you face anymore, please feel free to ask me. ;) Regards, Jijo. ;) ________________________________ Yesterday is history, Tomorrow is a mystery, But today is a present.