2 Replies Latest reply on Mar 25, 2011 8:27 AM by saibbot

    RCCE Shared Memory Allocation

    saibbot

      Hello,

       

      I stepped on the following issue: RCCE_shmalloc allocates one new RCCE_BLOCK (sizeof(RCCE_BLOCK)=12 bytes) in local memory for every shared memory allocation done, thus the local memory needed for allocating a (pointer to a) double for example is more than the actual shared memory space allocated.

       

      The program I attached, tries to allocate 100MB in single chars and fails (as expected, since it would need 1+GB for local metadata):

       

      for (i = 0; i < Bytes; i++) {
              p = (char *) RCCE_shmalloc(sizeof (char));
              if (!p) {
                  PRINTD("RCCE_shmalloc returned NULL (%d byte)", i);
           }
      }

      According to the output, the program fails after it had allocated around 17668KB = 17.67 MB. If my calculations are correct, the allocation till there needs 212MB of local memory. It fails with error code 137 (Segmentation Fault probably).

       

      I tried to figure out if it was the malloc call inside RCCE_shmalloc that returned NULL, but it wasn't (placed if(NULL) check after the RCCE_BLOCKs allocation).

       

      So, my conclusion is that the RCCE_shmalloc is trying to use space used by the OS (when calling the malloc for allocating the RCCE_BLOCK). Does it make sense, or am I missing something?

       

      PS. I am using RCCE 1.0.13, with SHMADD (512MB of shared memory)

        • 1. Re: RCCE Shared Memory Allocation
          Hayder

          Hi,

          I've tested your program. I guess the program and function shmalloc() return NULL from the use of the linked list inside body of shmalloc() and therefore you have already used a large number (about Million) of next pointer within the function shmalloc().

          regards.

          Hayder

          • 2. Re: RCCE Shared Memory Allocation
            saibbot

            As I said:

             

            I tried to figure out if it was the malloc call inside RCCE_shmalloc that returned NULL, but it wasn't (placed if(NULL) check after the RCCE_BLOCKs allocation).

            so it is not the case that the malloc within RCCE_shmalloc returned NULL.