linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* (unknown)
@ 2004-09-13 11:11 Ankit Jain
  2004-09-13 11:20 ` Ron Michael Khu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ankit Jain @ 2004-09-13 11:11 UTC (permalink / raw)
  To: gcc; +Cc: linux prg

hi

well i am fixed up in a new problem

i am using a array of size 1024*1024

it gives segmentation fault

it works with 512*512

my menory size is 128 mb and 512 swap

i have enough memory space and using gcc 3.2 v

may be i need to increase the memory size

how to do that?

ankit

________________________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 
http://uk.messenger.yahoo.com/download/index.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re:
  2004-09-13 11:11 (unknown) Ankit Jain
@ 2004-09-13 11:20 ` Ron Michael Khu
  2004-09-13 11:51 ` memory problem Ron Michael Khu
  2004-09-14 15:26 ` Ron Michael Khu
  2 siblings, 0 replies; 5+ messages in thread
From: Ron Michael Khu @ 2004-09-13 11:20 UTC (permalink / raw)
  To: Ankit Jain; +Cc: gcc, linux prg

did u try allocating it the dynamic way??
via a call to malloc or in a similar fashion?

Ankit Jain wrote:

>hi
>
>well i am fixed up in a new problem
>
>i am using a array of size 1024*1024
>
>it gives segmentation fault
>
>it works with 512*512
>
>my menory size is 128 mb and 512 swap
>
>i have enough memory space and using gcc 3.2 v
>
>may be i need to increase the memory size
>
>how to do that?
>
>ankit
>
>________________________________________________________________________
>Yahoo! Messenger - Communicate instantly..."Ping" 
>your friends today! Download Messenger Now 
>http://uk.messenger.yahoo.com/download/index.html
>-
>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>  
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* re: memory problem
  2004-09-13 11:11 (unknown) Ankit Jain
  2004-09-13 11:20 ` Ron Michael Khu
@ 2004-09-13 11:51 ` Ron Michael Khu
  2004-09-14 15:26 ` Ron Michael Khu
  2 siblings, 0 replies; 5+ messages in thread
From: Ron Michael Khu @ 2004-09-13 11:51 UTC (permalink / raw)
  To: Ankit Jain, linux prg, gcc-help

what method did u use to allocate memory??

static:
 char array[1024*1024] ;

dynamic
 char *array = (char*)calloc(  1024*1024, sizeof(char) );

and why r u allocating such huge chunks for an array?



Ankit Jain wrote:

>hi
>
>well i am fixed up in a new problem
>
>i am using a array of size 1024*1024
>
>it gives segmentation fault
>
>it works with 512*512
>
>my menory size is 128 mb and 512 swap
>
>i have enough memory space and using gcc 3.2 v
>
>may be i need to increase the memory size
>
>how to do that?
>
>ankit
>
>________________________________________________________________________
>Yahoo! Messenger - Communicate instantly..."Ping" 
>your friends today! Download Messenger Now 
>http://uk.messenger.yahoo.com/download/index.html
>-
>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>  
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re:
  2004-09-13 11:11 (unknown) Ankit Jain
  2004-09-13 11:20 ` Ron Michael Khu
  2004-09-13 11:51 ` memory problem Ron Michael Khu
@ 2004-09-14 15:26 ` Ron Michael Khu
  2 siblings, 0 replies; 5+ messages in thread
From: Ron Michael Khu @ 2004-09-14 15:26 UTC (permalink / raw)
  To: Ankit Jain; +Cc: gcc, linux prg

here 's an example of static and dynamic allocation...
(my prev example was only about single dimensional arrays...)

a 2dimensional array of  4450 x 4450
(change the dimension to 1450 x 1450 if  u find the
first size to be too big)

TEST.C
#include <stdio.h>
int main()
{
  double a[4450][4450];

  a[4449][0] = 999;
  printf( "%lf\n", a[4449][0] );
  return 1;
}


TEST2.c
#include <stdio.h>
int main()
{
  double **a;
  int i;

  a = (double**) calloc( 4450, sizeof(double*) );
  for ( i=0; i <1450; i++ )
  {
    a[i] = (double*) calloc( 4450, sizeof(double) );
  }

  a[4449][0]=999;
  printf( "%lf\n", a[4449][0] );
  return 1;
}




Ankit Jain wrote:

>hi
>
>well i am fixed up in a new problem
>
>i am using a array of size 1024*1024
>
>it gives segmentation fault
>
>it works with 512*512
>
>my menory size is 128 mb and 512 swap
>
>i have enough memory space and using gcc 3.2 v
>
>may be i need to increase the memory size
>
>how to do that?
>
>ankit
>
>________________________________________________________________________
>Yahoo! Messenger - Communicate instantly..."Ping" 
>your friends today! Download Messenger Now 
>http://uk.messenger.yahoo.com/download/index.html
>-
>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>  
>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* (unknown), 
@ 2009-04-09 17:46 postmaster
  0 siblings, 0 replies; 5+ messages in thread
From: postmaster @ 2009-04-09 17:46 UTC (permalink / raw)




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-04-09 17:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-13 11:11 (unknown) Ankit Jain
2004-09-13 11:20 ` Ron Michael Khu
2004-09-13 11:51 ` memory problem Ron Michael Khu
2004-09-14 15:26 ` Ron Michael Khu
  -- strict thread matches above, loose matches on Subject: below --
2009-04-09 17:46 (unknown), postmaster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).