Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Large (95MB) memory buffer allocation under Solaris

Status
Not open for further replies.

Sudmill

Programmer
Apr 20, 2001
65
GB
Hi,

I have a conversion issue, and as I havent programmed for Sun Solaris before Im a little stuck!
The following code allocates a large memory structure under windows;


hMyBufferHandle = HeapCreate(0, lSize, 0);
if(hMyBufferHandle == NULL)
printf("Error");
lpBuffer = VirtualAlloc(NULL,lSize, MEM_COMMIT,PAGE_READWRITE);


(If you spot any issues with this let me know!)

How do I do the same undex UNIX (Solaris 2.6) ? I need to be able to hold upto 95 Mb of data in this buffer.
I shall be using the gcc compiler if this helps ?!?!

Thanks alot for anyones time they spend looking at this.

Gratefully,

John.

 
You'll probably be able to do it using malloc(), given that you have enough memory:

#include <stdlib.h>

/* ... */

char *foo=malloc(95000000);
if (foo==NULL) {
/* error, couldn't allocate */
}

Russ
bobbitts@hotmail.com
 
Cheers Russ,

Wasnt sure about UNIX, but thought that might be the way.
THanks for all your knowledgable and valueable assistance.

Most appreciated !
 
Hi Sudmill,

Since your memory is of the order of 1 Gb I suggest that
you use memory mapping on Solaris. Mallocing out so much memory may not work when other memory-hungry applications are also running.

This link tells more about memory mapped buffers in Solaris.


Hope this helps.

abp :)
 
Thanks alot guys !
Much appreciated !

John.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top