Size of array too large

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • danieleghisi@gmail.com

    Size of array too large

    Hello

    I'm writing a small programme to look for some particular integer sets
    (homometric sets), and each one of this sets is a unsigned long long
    (e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
    sets of this kind, so I declared a

    #define MAXS = 397148160
    static unsigned long long set[MAXS];

    but MAXS seems to be a bit too large for my compiler (I'm using Xcode
    on a Mac Book Pro, 2.5GHz), that returns a "size of array too large"
    error.

    Is there a way to solve this problem and have a very long array of
    unsigned long long?

    Thank you very much
    Daniele Ghisi
  • Ian Collins

    #2
    Re: Size of array too large

    danieleghisi@gm ail.com wrote:
    Hello
    >
    I'm writing a small programme to look for some particular integer sets
    (homometric sets), and each one of this sets is a unsigned long long
    (e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
    sets of this kind, so I declared a
    >
    #define MAXS = 397148160
    static unsigned long long set[MAXS];
    >
    but MAXS seems to be a bit too large for my compiler (I'm using Xcode
    on a Mac Book Pro, 2.5GHz), that returns a "size of array too large"
    error.
    >
    Is there a way to solve this problem and have a very long array of
    unsigned long long?
    >
    Use dynamic allocation (malloc).

    Your array will be huge, over 3GB, so you better have plenty of RAM!

    --
    Ian Collins.

    Comment

    • A. Sinan Unur

      #3
      Re: Size of array too large

      danieleghisi@gm ail.com wrote in
      news:945ff496-791e-44b5-90c9-6fed76ffc5e8
      @k37g2000hsf.go oglegroups.co
      m:
      Hello
      >
      I'm writing a small programme to look for some particular integer
      sets (homometric sets), and each one of this sets is a unsigned
      long long (e.g. {1, 2, 4, 7} --1001011=75). I need to have a
      very long list of sets of this kind, so I declared a
      >
      #define MAXS = 397148160
      static unsigned long long set[MAXS];
      >
      but MAXS seems to be a bit too large for my compiler (I'm using
      Xcode on a Mac Book Pro, 2.5GHz), that returns a "size of array
      too large" error.
      >
      Is there a way to solve this problem and have a very long array of
      unsigned long long?
      I am assuming long long is 64 bits. So, if my arithmetic is correct,
      we are talking about approx 3 Gb memory just for this array.

      Methinks it's time to rethink the algorithm.

      Sinan

      --
      A. Sinan Unur <1usa@llenroc.u de.invalid>
      (remove .invalid and reverse each component for email address)

      Comment

      • Richard Tobin

        #4
        Re: Size of array too large

        In article <945ff496-791e-44b5-90c9-6fed76ffc5e8@k3 7g2000hsf.googl egroups.com>,
        <danieleghisi@g mail.comwrote:
        >#define MAXS = 397148160
        >static unsigned long long set[MAXS];
        If long long is 64 bits (which it is on your Mac), this requires over
        3GB of memory. If you compile in 32-bit mode, this is bigger than
        the system can handle. (The address space for 32-bit pointers is 4GB,
        but I think you can't have more than 2GB on the Mac.) Using malloc()
        instead won't help.

        It *should* work to build it as a 64-bit program - that is, one that
        uses 64-bit pointers. The flag for this on the Mac is -m64. However,
        it still doesn't seem to be able to handle it: apparently the size of
        the "bss" region is stored as a 32-bit number. If you malloc() the
        memory instead it should work with -m64.

        -- Richard
        --
        :wq

        Comment

        • Chris Thomasson

          #5
          Re: Size of array too large

          <danieleghisi@g mail.comwrote in message
          news:945ff496-791e-44b5-90c9-6fed76ffc5e8@k3 7g2000hsf.googl egroups.com...
          Hello
          >
          I'm writing a small programme to look for some particular integer sets
          (homometric sets), and each one of this sets is a unsigned long long
          (e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
          sets of this kind, so I declared a
          >
          #define MAXS = 397148160
          static unsigned long long set[MAXS];
          You have a syntax error here.

          [...]

          Comment

          • Ian Collins

            #6
            Re: Size of array too large

            Chris Thomasson wrote:
            <danieleghisi@g mail.comwrote in message
            news:945ff496-791e-44b5-90c9-6fed76ffc5e8@k3 7g2000hsf.googl egroups.com...
            >Hello
            >>
            >I'm writing a small programme to look for some particular integer sets
            >(homometric sets), and each one of this sets is a unsigned long long
            >(e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
            >sets of this kind, so I declared a
            >>
            >#define MAXS = 397148160
            >static unsigned long long set[MAXS];
            >
            You have a syntax error here.
            >
            Where?

            --
            Ian Collins.

            Comment

            • Richard Tobin

              #7
              Re: Size of array too large

              In article <66q2fqF2jvuo0U 13@mid.individu al.net>,
              Ian Collins <ian-news@hotmail.co mwrote:
              >>#define MAXS = 397148160
              >>static unsigned long long set[MAXS];
              >You have a syntax error here.
              >Where?
              The equals in the #define. But that's obviously just a typo,
              not the real problem.

              -- Richard
              --
              :wq

              Comment

              • Peter Nilsson

                #8
                Re: Size of array too large

                Ian Collins wrote:
                Chris Thomasson wrote:
                <danieleghisi@g mail.comwrote
                #define MAXS = 397148160
                static unsigned long long set[MAXS];
                You have a syntax error here.
                Where?
                It's a classic 'trap for young players'. ;-)

                --
                Peter

                Comment

                • Ian Collins

                  #9
                  Re: Size of array too large

                  Richard Tobin wrote:
                  In article <66q2fqF2jvuo0U 13@mid.individu al.net>,
                  Ian Collins <ian-news@hotmail.co mwrote:
                  >
                  >>>#define MAXS = 397148160
                  >>>static unsigned long long set[MAXS];
                  >
                  >>You have a syntax error here.
                  >
                  >Where?
                  >
                  The equals in the #define. But that's obviously just a typo,
                  not the real problem.
                  >
                  Ah yes, I was looking at the array declaration.

                  --
                  Ian Collins.

                  Comment

                  • danieleghisi@gmail.com

                    #10
                    Re: Size of array too large

                    On 18 Apr, 00:42, "Chris Thomasson" <cris...@comcas t.netwrote:
                    <danielegh...@g mail.comwrote in message
                    >
                    news:945ff496-791e-44b5-90c9-6fed76ffc5e8@k3 7g2000hsf.googl egroups.com...
                    >
                    Hello
                    >
                    I'm writing a small programme to look for some particular integer sets
                    (homometric sets), and each one of this sets is a unsigned long long
                    (e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
                    sets of this kind, so I declared a
                    >
                    #define MAXS = 397148160
                    static unsigned long long set[MAXS];
                    >
                    You have a syntax error here.
                    >
                    [...]
                    Yap, sure... It was a typo, i didn't copy-paste! :p

                    Thanks everybody for the answers... It's hard to find another way for
                    the algorithm, so i'll try to follow your advices.
                    My mac has 2GB of Ram, but I just bought 2 additional Gb :p

                    Comment

                    • Ian Collins

                      #11
                      Re: Size of array too large

                      danieleghisi@gm ail.com wrote:
                      On 18 Apr, 00:42, "Chris Thomasson" <cris...@comcas t.netwrote:
                      ><danielegh...@ gmail.comwrote in message
                      >>
                      >news:945ff49 6-791e-44b5-90c9-6fed76ffc5e8@k3 7g2000hsf.googl egroups.com...
                      >>
                      >>Hello
                      >>I'm writing a small programme to look for some particular integer sets
                      >>(homometric sets), and each one of this sets is a unsigned long long
                      >>(e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
                      >>sets of this kind, so I declared a
                      >>#define MAXS = 397148160
                      >>static unsigned long long set[MAXS];
                      >You have a syntax error here.
                      >>
                      >[...]
                      >
                      Yap, sure... It was a typo, i didn't copy-paste! :p
                      >
                      Thanks everybody for the answers... It's hard to find another way for
                      the algorithm, so i'll try to follow your advices.
                      My mac has 2GB of Ram, but I just bought 2 additional Gb :p
                      You'll probably still run out!

                      --
                      Ian Collins.

                      Comment

                      • Bartc

                        #12
                        Re: Size of array too large


                        <danieleghisi@g mail.comwrote in message
                        news:778820bc-4483-4e31-91ec-92b5b66402a6@8g 2000hsu.googleg roups.com...
                        On 18 Apr, 00:42, "Chris Thomasson" <cris...@comcas t.netwrote:
                        ><danielegh...@ gmail.comwrote in message
                        >>
                        >news:945ff49 6-791e-44b5-90c9-6fed76ffc5e8@k3 7g2000hsf.googl egroups.com...
                        >>
                        Hello
                        >>
                        I'm writing a small programme to look for some particular integer sets
                        (homometric sets), and each one of this sets is a unsigned long long
                        (e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
                        sets of this kind, so I declared a
                        >>
                        #define MAXS = 397148160
                        static unsigned long long set[MAXS];
                        Thanks everybody for the answers... It's hard to find another way for
                        the algorithm, so i'll try to follow your advices.
                        My mac has 2GB of Ram, but I just bought 2 additional Gb :p
                        If your /compiler/ is reporting the memory problem, extra ram might not
                        help.

                        --
                        Bart



                        Comment

                        • Ian Collins

                          #13
                          Re: Size of array too large

                          Bartc wrote:
                          <danieleghisi@g mail.comwrote in message
                          news:778820bc-4483-4e31-91ec-92b5b66402a6@8g 2000hsu.googleg roups.com...
                          >On 18 Apr, 00:42, "Chris Thomasson" <cris...@comcas t.netwrote:
                          >><danielegh... @gmail.comwrote in message
                          >>>
                          >>news:945ff4 96-791e-44b5-90c9-6fed76ffc5e8@k3 7g2000hsf.googl egroups.com...
                          >>>
                          >>>Hello
                          >>>I'm writing a small programme to look for some particular integer sets
                          >>>(homometri c sets), and each one of this sets is a unsigned long long
                          >>>(e.g. {1, 2, 4, 7} --1001011=75). I need to have a very long list of
                          >>>sets of this kind, so I declared a
                          >>>#define MAXS = 397148160
                          >>>static unsigned long long set[MAXS];
                          >
                          >Thanks everybody for the answers... It's hard to find another way for
                          >the algorithm, so i'll try to follow your advices.
                          >My mac has 2GB of Ram, but I just bought 2 additional Gb :p
                          >
                          If your /compiler/ is reporting the memory problem, extra ram might not
                          help.
                          >
                          it was barfing in the size of a static array. Dynamic allocation is a
                          different kettle of fish.

                          --
                          Ian Collins.

                          Comment

                          • Harry Skelton

                            #14
                            Re: Size of array too large

                            Ian Collins wrote:
                            it was barfing in the size of a static array. Dynamic allocation is a
                            different kettle of fish.
                            ....and you could always do disk cached array, if you lack memory. Just
                            build it as a class that fetches the record involved.

                            Comment

                            • Kenny McCormack

                              #15
                              Re: Size of array too large

                              In article <480a19a3$0$220 77$6e1ede2f@rea d.cnntp.org>,
                              Harry Skelton <skelton.harry@ gmail.comwrote:
                              >Ian Collins wrote:
                              >it was barfing in the size of a static array. Dynamic allocation is a
                              >different kettle of fish.
                              >
                              >...and you could always do disk cached array, if you lack memory. Just
                              >build it as a class that fetches the record involved.
                              You are not allowed to use the "c-word" (cl*ss) in this NG (clc).

                              Comment

                              Working...