Fedora Linux Support Community & Resources Center
  #1  
Old 30th September 2007, 12:46 AM
ahm_irf Offline
Registered User
 
Join Date: Feb 2007
Posts: 33
allocation of four dimensional array memory

I need four dimensional array like
double a[256][256][256][256];


but the size is too big to use an array.

If I use only pointer like
double ****a;

to allocate this memory, I have to run 3 loops to allocate memory ..which takes lots of time.
a = (double **** ) malloc (sizeof(double ***)*256);
for(i=0;i<256;i++)
{
a[i] = (double ***) malloc ( sizeof(double **)*256);
for(j=0;j<256;j++)
{
a[i][j] = (double **) malloc ( sizeof(double *)*256);
for(k=0;k<256;k++)
{
a[i][j][k] = (double *) malloc ( sizeof(double )*256);
}
}
}


is there any other work around ....?

I was thinking to use *a[256][256][256]
Can I use this ...and if yes how I can allocate the memory for this...?
Reply With Quote
  #2  
Old 30th September 2007, 02:33 AM
ppesci's Avatar
ppesci Offline
Registered User
 
Join Date: May 2006
Location: Caracas, Venezuela
Posts: 1,828
Anyway, the memory needed by any method is about 32GB, that is:

256*256*256*256*8

Your RAM + swap space must be greater than 32GB. If you doesn't have that much memory, think to using your HD to allocate portions of the array, and load/save on demand.

HTH
__________________
Pietro Pesci Feltri

PowerBook 15" G4 and
MacBook Pro 17" Intel Core 2 Duo
Intel I5 Desktop
Reply With Quote
  #3  
Old 30th September 2007, 03:50 AM
stevea's Avatar
stevea Offline
Registered User
 
Join Date: Apr 2006
Location: Ohio, USA
Posts: 8,298
But the 32GB is not even addressable unless he's got a processor with PAE, otherwise it 4GB per process max.


Perhaps if ahm_irf described what he is trying to do I could point him in a better direction.
Reply With Quote
Reply

Tags
allocation, array, dimensional, memory

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
User Memory Allocation JBLoudG20 Using Fedora 7 29th July 2009 11:59 PM
Memory Allocation Between Host and 2 Xen Domains madjack59 Servers & Networking 0 24th October 2007 06:54 PM
Dynamic Memory Allocation in C Peter_APIIT Programming & Packaging 9 26th December 2006 12:08 PM
Memory allocation problem during install (FC1) Vorknkx EOL (End Of Life) Versions 5 21st June 2004 12:18 PM


Current GMT-time: 00:08 (Sunday, 19-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat