Professional Web Applications Themes

Shared Memory Programming - dynamic deallocation - UNIX Programming

Hi all I am new to shared memory programing, and I am working on Solaris. I have been successful in using shmget and shmat to share a segment of memory and attach it and access from another program. Now I need to allocate memory dynamically. So I have written a class to allocate memory from the shared segment not from heap. But now I am having the problem when freeing memory because it is going to keep holes in my shared portion. What I have been using was the starting point of the shared memory portion with an offset of ...

  1. #1

    Default Shared Memory Programming - dynamic deallocation

    Hi all
    I am new to shared memory programing, and I am working on Solaris. I
    have been successful in using shmget and shmat to share a segment of
    memory and attach it and access from another program.
    Now I need to allocate memory dynamically. So I have written a class
    to allocate memory from the shared segment not from heap. But now I am
    having the problem when freeing memory because it is going to keep
    holes in my shared portion. What I have been using was the starting
    point of the shared memory portion with an offset of which no of bytes
    have been allocated. with this structure I am unable to re-use the
    freed memory from the middle of my memory block.
    I would really appriciate any suggessions or references.
    Many thanks in advance
    Rekha
    Rekha Guest

  2. #2

    Default Re: Shared Memory Programming - dynamic deallocation

    In article <google.com>,
    com (Rekha) wrote:
     

    You need to keep a free list or free bitmap that indicates what portions
    of the shared memory are available, and reuse them when possible. This
    is basically what malloc() does with the regular heap.

    I suggest you get a book on algorithms and data structures that has a
    chapter on memory management. It should provide some direction.

    Another possibility is to get glibc. I think its malloc() includes a
    way for it to allocate out of a heap block that you supply, which can be
    shared memory.

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    Barry Guest

  3. #3

    Default Re: Shared Memory Programming - dynamic deallocation

    Rekha wrote: 

    I'm not sure if Solaris provides "amalloc".

    See:

    http://btrcx1.cip.uni-bayreuth.de/cgi-bin/manpages/amalloc/3

    Or maybe you can use this :

    http://www.ossp.org/pkg/lib/mm/

    Gianni Guest

Similar Threads

  1. Shared memory and Mac OS X
    By Wes in forum PostgreSQL / PGSQL
    Replies: 5
    Last Post: February 22nd, 04:01 AM
  2. Shared Memory/Shared Buffers
    By Alex Turner in forum PostgreSQL / PGSQL
    Replies: 1
    Last Post: January 28th, 04:09 PM
  3. help solaris thread+shared library with shared memory
    By inderjeet in forum UNIX Programming
    Replies: 4
    Last Post: December 15th, 05:03 PM
  4. shared memory and dynamic data structures
    By Måns in forum UNIX Programming
    Replies: 4
    Last Post: August 12th, 10:25 PM
  5. I think I need a DB with no shared memory
    By dimonex in forum Informix
    Replies: 1
    Last Post: July 3rd, 05:20 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139