I came across the following problem. I create shared memory, then I close it
and unlink it. The memory does not get freed.
I used the examples programs of the docs (shm_open) and just added a loop to
continuously created and destroy shared memory. The program works fine in
QNX4 (after changing ftruncate to ltrunc). In QNX6.1, I get a memory
overflow after some time. Just look at the memory bar of the shelf.
Program is attached.
Markus
begin 666 docex.c
M(VEN8VQU9&4@/’-T9&EO+F@^#0HC:6YC;'5D92 <W1R:6YG+F@^#0HC:6YC
M;‘5D92 \9F-N=&PN:#X-"B-I;F-L=61E(#QE<G)N;RYH/@T*(VEN8VQU9&4@
M/’-T9&QI8BYH/@T*(VEN8VQU9&4@/‘5N:7-T9"YH/@T*(VEN8VQU9&4@/&QI
M;6ET<RYH/@T*(VEN8VQU9&4@/’-Y<R]M;6%N+F@^#0H-“B-D969I;F4@0E5&
M1D527U-)6D4@(#4P,# P,# -”@T*:6YT(&UA:6XH(&EN="!A<F=C+"!C:&%R
MBH@87)G=B I#0I[#0H@(" @:6YT(&9D.PT(" @(&EN="!I.PT*(" @('5N
M<VEG;F5DB!A9&1R.PT#0IF;W(@&D@/2 P.R [:2LK0T*>PT*“7-L965P
M*#$I.PT*“7!R:6YT9B@B)61<;B(L(&DI.PT*(” @(”\J#0H@(" @(“H@26X@
M8V%S92!T:&4@=6YL:6YK(&-O9&4@:7-N)W0@97AE8W5T960@870@=&AE(&5N
M9 T*(” @(" J+PT*(" @(&EF*"!A<F=C("$](#$@2![#0H@(" @(" @(’-H
M;5]U;FQI;FLH("(O8F]L=’,B(“D[#0H@(” @(" @(’)E='5R;B!%6$E47U-5
M0T-%4U,[#0H@(" @?0T#0H@(" @+RH@0W)E871E(&$@;F5W(&UE;6]R>2!O
M8FIE8W0@B-“B @(”!F9" ](’-H;5]O<&5N" B+V)O;‘1S(BP@3U]21%=2
M(‘P@3U]#4D5!5"P@,#<W-R I.PT*(" @(&EF*"!F9" ]/2 M,2 I(‘L-“B @
M(” @(" @9G!R:6YT9B@@<W1D97)R+" B3W!E;B!F86EL960Z)7-<;B(L#0H@
M(" @(" @(" @("!S=’)E<G)O<B@@97)R;F@2 I.PT(" @(" @("!R971U
M<FX@15A)5%]&04E,55)%.PT*(" @(‘T-“B @(” -“B @(” OB!3970@=&AE
M(&UE;6]R>2!O8FIE8W0G<R!S:7IE(“HO#0H@(” @:68H(&9T<G5N8V%T92@@
M9F0L($)51D9%4E]325I%(“D@/3T@+3$@2![#0H@(" @(" @(&9P<FEN=&8H
M(’-T9&5R<BP@(F9T<G5N8V%T93H@)7-<;B(L#0H@(" @(" @(" @("!S=’)E
M<G)O<B@@97)R;F@2 I.PT(" @(" @("!R971U<FX@15A)5%]&04E,55)%
M.PT(” @('T-"@T(" @("\J($UA<"!T:&4@;65M;W)Y(&]B:F5C=" J+PT*
M(" @(&%D9’(@/2!M;6%P*" P+"!S:7IE;V8H(“IA9&1R(“DL#0H@(” @(” @
M(" @("!04D]47U)%040@?"!04D]47U=2251%+ T*(" @(" @(" @(" @34%0
M7U-(05)%1"P@9F0L(# @3L-“B @(”!I9B@@861D<B ]/2!-05!?1D%)3$5$
M("D@>PT(" @(" @("!F<’)I;G1F*"!S=&1E<G(L(")M;6%P(&9A:6QE9#H@
M)7-<;B(L#0H@(" @(" @(" @("!S=’)E<G)O<B@@97)R;F@2 I.PT(" @
M(" @("!R971U<FX@15A)5%]&04E,55)%.PT*(" @(‘T-"@T*(" @(’!R:6YT
M9B@@(DUA<"!A9&1R(&ES(#!X)3 X>%QN(BP@861D<B I.PT*#0H@(" @+RH@
M5W)I=&4@=&@<VAA<F5D(&UE;6]R>2 J+PT*(" @(“IA9&1R(#T@,3L-”@T*
M(" @("\J#0H@(" @(“H@5&AE(&UE;6]R>2!O8FIE8W0@<F5M86EN<R!I;@T*
M(” @(" J(‘1H92!S>7-T96T@869T97(@=&AE(&-L;W-E#0H@(" @(“HO#0H@
M(” @<VQE97 H,2D[#0H@(" @8VQO<V4H(&9D(“D[#0H-“B @(” O*@T*(” @
M(" J(%1O(’)E;6]V92!A(&UE;6]R>2!O8FIE8W0-“B @(” @B!Y;W4@;75S
M="!U;FQI;FL@:70@;&EK92!A(&9I;&4N#0H@(" @("H-“B @(” @B!4:&ES
M(&UA>2!B92!D;VYE(&)Y(&%N;W1H97(@<’)O8V5S<RX-“B @(” @B-“B @
M(”!S:&U?=6YL:6YK" B+V)O;'1S(B I.PT?0T#0H@(" @<F5T=7)N($58
0251?4U5#0T534SL-“GT-”@``
`
end
Markus Loffler <loffler@ces.clemson.edu> wrote:
I came across the following problem. I create shared memory, then I close it
and unlink it. The memory does not get freed.
I used the examples programs of the docs (shm_open) and just added a loop to
continuously created and destroy shared memory. The program works fine in
QNX4 (after changing ftruncate to ltrunc). In QNX6.1, I get a memory
overflow after some time. Just look at the memory bar of the shelf.
Program is attached.
You program is not unmapping the memory it maps in. QNX6 counts all
refences to the shared object (both fd & mappings), and only frees the
memory after unlink, all opens are closed & all maps are unmapped.
unmaps & closes are done automatically at process death – unlinks must
be done explicitly.
(I consider this better behaviour than that under QNX4.)
-David
–
QNX Training Services
dagibbs@qnx.com
Thanks David - that makes sense
Markus
“David Gibbs” <dagibbs@qnx.com> wrote in message
news:9kcikq$l7m$3@nntp.qnx.com…
Markus Loffler <> loffler@ces.clemson.edu> > wrote:
I came across the following problem. I create shared memory, then I
close it
and unlink it. The memory does not get freed.
I used the examples programs of the docs (shm_open) and just added a
loop to
continuously created and destroy shared memory. The program works fine
in
QNX4 (after changing ftruncate to ltrunc). In QNX6.1, I get a memory
overflow after some time. Just look at the memory bar of the shelf.
Program is attached.You program is not unmapping the memory it maps in. QNX6 counts all
refences to the shared object (both fd & mappings), and only frees the
memory after unlink, all opens are closed & all maps are unmapped.unmaps & closes are done automatically at process death – unlinks must
be done explicitly.(I consider this better behaviour than that under QNX4.)
-David
–
QNX Training Services
dagibbs@qnx.com
However, the example in the docs should be adapted to have a unmap() call as
well
Markus
“Markus Loffler” <loffler@ces.clemson.edu> wrote in message
news:9keeq0$qcj$1@inn.qnx.com…
Thanks David - that makes sense
Markus“David Gibbs” <> dagibbs@qnx.com> > wrote in message
news:9kcikq$l7m$> 3@nntp.qnx.com> …
Markus Loffler <> loffler@ces.clemson.edu> > wrote:
I came across the following problem. I create shared memory, then I
close it
and unlink it. The memory does not get freed.
I used the examples programs of the docs (shm_open) and just added a
loop to
continuously created and destroy shared memory. The program works fine
in
QNX4 (after changing ftruncate to ltrunc). In QNX6.1, I get a memory
overflow after some time. Just look at the memory bar of the shelf.
Program is attached.You program is not unmapping the memory it maps in. QNX6 counts all
refences to the shared object (both fd & mappings), and only frees the
memory after unlink, all opens are closed & all maps are unmapped.unmaps & closes are done automatically at process death – unlinks must
be done explicitly.(I consider this better behaviour than that under QNX4.)
-David
–
QNX Training Services
dagibbs@qnx.com
Markus Loffler <loffler@ces.clemson.edu> wrote:
However, the example in the docs should be adapted to have a unmap() call as
well
Hm… probably, of course the example does exit almost immediately which
will cause an automatic unmapping of its memory.
Still, it would probably be clearer.
(And, the shm_unlink() page does explicitly state all open and map
references before deletion.)
-David
–
QNX Training Services
dagibbs@qnx.com