some help with Shared Memory

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

    some help with Shared Memory

    Hi,

    Im a Java developer new to PHP development. Im tasked to do some
    development playing with Shared Memory (shm http://forums.devshed.com/php-development-5/).
    Im a little curious about the consequences that are a little unclear
    in the documentation.

    If I create a shared memory block of x bytes.

    1) How do I check the total that are being *used*. With
    shm_size I can find out the shared memory size but not the size that
    are used in that block. I need a mechanism to determine whether Im
    close to a certain high water mark of the memory block

    2) Can you "resize" a memory block if I get full? Or do I have
    to make a new block, copy everything over ala ArrayList in Java?

    Thanks for your help,
    Victor
  • =?UTF-8?B?SXbDoW4gU8OhbmNoZXogT3J0ZWdh?=

    #2
    Re: some help with Shared Memory

    victor.s.email@ gmail.com wrote:
    If I create a shared memory block of x bytes.
    >
    1) How do I check the total that are being *used*.
    Please define "use".
    2) Can you "resize" a memory block if I get full?
    Please refer to a POSIX C programming manual for a full reference on how to
    work with shared memory blocks. PHP doesn't reimplement anything, it just
    calls most of the POSIX C interface as transparently as possible.


    Anyway, general tips: When you're working with shared mem, you're supposed
    to know what your doing. You're supposed to know how C memory management
    works. Do not rely on Java (or any other high-level language) assumptions
    on how the memory system works.

    --
    ----------------------------------
    Iván Sánchez Ortega -ivan-algarroba-sanchezortega-punto-es-

    The secret source of humor is not joy but sorrow; there is no humor in
    Heaven.
    -- Mark Twain

    Comment

    • Tim Roberts

      #3
      Re: some help with Shared Memory

      "victor.s.email @gmail.com" <victor.s.email @gmail.comwrote :
      >
      If I create a shared memory block of x bytes.
      >
      1) How do I check the total that are being *used*. With
      >shm_size I can find out the shared memory size but not the size that
      >are used in that block. I need a mechanism to determine whether Im
      >close to a certain high water mark of the memory block
      As soon as you create a shared memory block of X bytes, as far as the
      operating system is concerned, all X bytes are "used". It is entirely up
      to you to decide what to do with that memory. If you are storing things in
      that block, then it's up to you to track the usage.

      The operating system will not allocate memory out of your shared block.
      It's up to you.
      --
      Tim Roberts, timr@probo.com
      Providenza & Boekelheide, Inc.

      Comment

      • C. (http://symcbean.blogspot.com/)

        #4
        Re: some help with Shared Memory

        On 14 Oct, 02:38, "victor.s.em... @gmail.com"
        <victor.s.em... @gmail.comwrote :
        Hi,
        >
        Im a Java developer new to PHP development. Im tasked to do some
        development playing with Shared Memory (shmhttp://forums.devshed. com/php-development-5/).
        Im a little curious about the consequences that are a little unclear
        in the documentation.
        >
        If I create a shared memory block of x bytes.
        >
        1) How do I check the total that are being *used*. With
        shm_size I can find out the shared memory size but not the size that
        are used in that block. I need a mechanism to determine whether Im
        close to a certain high water mark of the memory block
        >
        2) Can you "resize" a memory block if I get full? Or do I have
        to make a new block, copy everything over ala ArrayList in Java?
        >
        Thanks for your help,
        Victor
        As others have pointed out - its all well documented.

        But I suspect you may be using shm because you're still designing your
        programs as if they were Java programs running in threads. Although
        there are uses for shm with PHP, they are somewhat niche. You may want
        to take a long hard look at whether shm is the right PHP way to solve
        your current problem.

        C.

        Comment

        Working...