array in C program - SUN

This is a discussion on array in C program - SUN ; How do I determine what the maximum of array I can use in C program? I have Sun Solaris. How many array I can declare, I know it depends on memory. If I have set line[100000] in my C program, ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: array in C program

  1. array in C program

    How do I determine what the maximum of array I can use in C program?

    I have Sun Solaris. How many array I can declare, I know it depends on
    memory.

    If I have set line[100000] in my C program, how many memory do I need?






    Thanks



  2. Re: array in C program

    "cljlk" writes in comp.unix.solaris:
    |How do I determine what the maximum of array I can use in C program?
    |I have Sun Solaris. How many array I can declare, I know it depends on
    |memory.

    You divide the maximum memory your program can allocate by the size
    of the array members.

    The maximum memory your program can allocate is the smallest number on
    this list:
    - the total amount of virtual memory (RAM + swap) free at runtime,
    minus whatever overhead your program needs to load itself and
    set up it's stack (see the "available" number in 'swap -s')
    - Approx. 3.9GB if running a 32-bit process on a recent Solaris
    - the value of ulimit -d if it's not set to 'unlimited'


    |If I have set line[100000] in my C program, how many memory do I need?

    100000 times the size of whatever datatype that variable is.
    If it's a char, 100000 bytes. If it's an int, 400000 bytes.

    --
    __________________________________________________ ______________________
    Alan Coopersmith alanc@alum.calberkeley.org
    http://www.CSUA.Berkeley.EDU/~alanc/ aka: Alan.Coopersmith@Sun.COM
    Working for, but definitely not speaking for, Sun Microsystems, Inc.

  3. Re: array in C program

    Alan Coopersmith wrote:

    > "cljlk" writes in comp.unix.solaris:
    > |How do I determine what the maximum of array I can use in C program?
    > |I have Sun Solaris. How many array I can declare, I know it depends on
    > |memory.
    >
    > You divide the maximum memory your program can allocate by the size
    > of the array members.


    Actually it depends if the array is a local variable (on the stack)
    or a global variable (on the heap). You program has a fixed size
    stack (than can be adjusted with some ELF/ld tweaks), but the heap
    can grow to the max ram size allowed for a process on your system.

    -Wayne


+ Reply to Thread