<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: P0 space of memory leak in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147552#M14205</link>
    <description>If you want us to debug for you, you have to show us the code that isn't working.&lt;BR /&gt;&lt;BR /&gt;Given no more info than what you have provided, my GUESS is that sect_mask has the SEC$M_EXPREG bit set.&lt;BR /&gt;&lt;BR /&gt;From the SSREF $MGBLSC description:&lt;BR /&gt;&lt;BR /&gt;"When the SEC$M_EXPREG flag is set, the second inadr longword is ignored, while bit 30 (the second most significant bit) of the first inadr longword is used to determine the region of choice. If the bit is clear, P0 is chosen; if the bit is set, P1 is chosen."&lt;BR /&gt;&lt;BR /&gt;When that bit is set, and the inadr contains a P0 address, the virtual address used begins at the page above the highest current P0 page that is mapped.&lt;BR /&gt;&lt;BR /&gt;It appears that something your program did after the first global section was mapped, allocated some space in P0.  Look at the values that were returned in the first call, the highest address 254255103 decimal or 0xF279FFF &amp;lt;- Note high end of a page, when you mapped the second time the low end was at 254672896 decimal or 0xF2E0000 &amp;lt;- Note start of a new page)&lt;BR /&gt;&lt;BR /&gt;So something mapped 417792 bytes (51 Alpha pages) after the address space that you mapped the first time.&lt;BR /&gt;&lt;BR /&gt;237772800 bytes (29025 Alpha Pages) mapped first time&lt;BR /&gt;237772800 bytes (29025 Alpha Pages) mapped second time&lt;BR /&gt;&lt;BR /&gt;Are you mapping different global sections each time through?  If not, then why are you deleting the virtual address space, just to remap it? If it is a different global section, but every global section is the same size, then clear the SEC$M_EXPREG after the map it the first time, and just reuse the same address space that got returned the first time.  If they are not all the same size, then you have a problem.  You will have to allocate enough for the largest global section, and just reuse the space starting at the same base address.&lt;BR /&gt;&lt;BR /&gt;Jon</description>
    <pubDate>Wed, 20 Feb 2008 09:36:21 GMT</pubDate>
    <dc:creator>Jon Pinkley</dc:creator>
    <dc:date>2008-02-20T09:36:21Z</dc:date>
    <item>
      <title>P0 space of memory leak</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147550#M14203</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have some problem with the P0 space leaking memory.&lt;BR /&gt;&lt;BR /&gt;I am using sys$mgblsc function to map global section and sys$deltva to free up that memory space. Code flow is as follows:&lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;1   RECALL:&lt;BR /&gt;&lt;BR /&gt;2 [Wait for the request from user]&lt;BR /&gt;&lt;BR /&gt; /* Got the request from user */&lt;BR /&gt;&lt;BR /&gt;3 &lt;IF memory="" is="" already="" mapped=""&gt;&lt;BR /&gt;&lt;BR /&gt;  /* First time memory will not be mapped so the following statement will not be executed */&lt;BR /&gt;&lt;BR /&gt;4  SYS$DELTVA (pc_gs_bounds, retadr, 0 ) &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; /* Map the memory */&lt;BR /&gt;&lt;BR /&gt;5 sys$mgblsc&lt;BR /&gt;&lt;BR /&gt;        status = SYS$MGBLSC ( inadr,&lt;BR /&gt;                              pc_gs_bounds, 0,&lt;BR /&gt;                              sect_mask,&lt;BR /&gt;                              &amp;amp;cache_gs_ds,&lt;BR /&gt;                              gs_ident, 0 ) ;&lt;BR /&gt;&lt;BR /&gt;6 [ Now execute the remaining part of the code ]&lt;BR /&gt;&lt;BR /&gt;7 [ Everthing done, goto RECALL ]&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;I am running the debug image of the code along with heap analyzer and I am having some confusing results:&lt;BR /&gt;&lt;BR /&gt;Giving request for FIRST Time:&lt;BR /&gt;=============================&lt;BR /&gt;&lt;BR /&gt;Program counter is at 2 and it is waiting for the request from user, I entered the request it checks the whether the memory is mapped or not ( at 3) since for the first time it is not mapped so 4 will not be executed and it comes directly to 5. After the exectuion of 5 global section section of memory is mapped onto the P0 space of the process.&lt;BR /&gt;&lt;BR /&gt;From Heap Analyzer:&lt;BR /&gt;&lt;BR /&gt;Mapped at following location:&lt;BR /&gt; 00FB8000+0E2C2000=0F27A000 SYS$MGBLSC - "XXXXXXXX" (P0 Region). &lt;BR /&gt;&lt;BR /&gt;From f$getjpi(pid,"FREP0VA")&lt;BR /&gt; Before step 5:  00A8F4DE&lt;BR /&gt; After step 5:  0F2E0000&lt;BR /&gt;&lt;BR /&gt;Value of pc_gs_bounds[0:1] from debug image:&lt;BR /&gt;    [0]:        16482304&lt;BR /&gt;    [1]:        254255103&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;After this execution of the program completes and it again goes at 2, waiting for request from user. Everthing works fine till here.&lt;BR /&gt;&lt;BR /&gt;Giving request for SECOND Time:&lt;BR /&gt;==============================&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now I give the request second time. Since memory is mapped the previous time so it goes at step 4.  Return value at 4 is SS$_SUCCESS. But I got some contradictory results from heap analyzer and f$getjpi.&lt;BR /&gt;&lt;BR /&gt;From Heap Analyzer:&lt;BR /&gt;&lt;BR /&gt;Memory is unmaped, but&lt;BR /&gt;&lt;BR /&gt;From f$getjpi(pid,"FREP0VA")&lt;BR /&gt;&lt;BR /&gt;It still gives: 0F2E0000&lt;BR /&gt;&lt;BR /&gt;Values of pc_gs_bounds and retadr at 4 are:&lt;BR /&gt;&lt;BR /&gt;decedi$pc_gs_bounds[0:1]&lt;BR /&gt;    [0]:        16482304&lt;BR /&gt;    [1]:        254255103&lt;BR /&gt;retadr[0:1]&lt;BR /&gt;    [0]:        16482304&lt;BR /&gt;    [1]:        254255103&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Now it comes at step 5. After execution of step 5, results are as follows:&lt;BR /&gt;&lt;BR /&gt;Form Heap Analyzer:&lt;BR /&gt;&lt;BR /&gt;Memory is again mapped at following location:&lt;BR /&gt;&lt;BR /&gt; 0F2E0000+0E2C2000=1D5A2000 SYS$MGBLSC - "XXXXXXXX" (P0 Region).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;From f$getjpi(pid,"FREP0VA")&lt;BR /&gt;&lt;BR /&gt; It increases its value and gives: 1D5A2000&lt;BR /&gt;&lt;BR /&gt;Value of pc_gs_bounds[0:1] from debug image:&lt;BR /&gt;    [0]:        254672896&lt;BR /&gt;    [1]:        492445695&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Can anyone help me to know &lt;BR /&gt;&lt;BR /&gt;1) Where P0 memory is being leaked above. Even after making a call to sys$deltva f$getpi shows 0F2E0000 and after calling sys$mgblsce it increases it value to 1D5A2000.&lt;BR /&gt;&lt;BR /&gt;2) When we are mapping the same global section again then why not it is being mapped at the same location of P0 which we have just freed above at step 4.&lt;BR /&gt;&lt;BR /&gt;Hope I am clear in my questions. Please let me know if any clarification is required or if I have done some mistake.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;ajaydec&lt;/IF&gt;</description>
      <pubDate>Wed, 20 Feb 2008 05:38:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147550#M14203</guid>
      <dc:creator />
      <dc:date>2008-02-20T05:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: P0 space of memory leak</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147551#M14204</link>
      <description>ajaydec,&lt;BR /&gt;&lt;BR /&gt;please read through this thread&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1198013" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1198013&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;which discusses the checkerboarding effect of repated allocation and deallocation of memory in a process.&lt;BR /&gt;&lt;BR /&gt;It should help you understand what you are seeing in your own application.&lt;BR /&gt;&lt;BR /&gt;Duncan</description>
      <pubDate>Wed, 20 Feb 2008 09:32:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147551#M14204</guid>
      <dc:creator>Duncan Morris</dc:creator>
      <dc:date>2008-02-20T09:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: P0 space of memory leak</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147552#M14205</link>
      <description>If you want us to debug for you, you have to show us the code that isn't working.&lt;BR /&gt;&lt;BR /&gt;Given no more info than what you have provided, my GUESS is that sect_mask has the SEC$M_EXPREG bit set.&lt;BR /&gt;&lt;BR /&gt;From the SSREF $MGBLSC description:&lt;BR /&gt;&lt;BR /&gt;"When the SEC$M_EXPREG flag is set, the second inadr longword is ignored, while bit 30 (the second most significant bit) of the first inadr longword is used to determine the region of choice. If the bit is clear, P0 is chosen; if the bit is set, P1 is chosen."&lt;BR /&gt;&lt;BR /&gt;When that bit is set, and the inadr contains a P0 address, the virtual address used begins at the page above the highest current P0 page that is mapped.&lt;BR /&gt;&lt;BR /&gt;It appears that something your program did after the first global section was mapped, allocated some space in P0.  Look at the values that were returned in the first call, the highest address 254255103 decimal or 0xF279FFF &amp;lt;- Note high end of a page, when you mapped the second time the low end was at 254672896 decimal or 0xF2E0000 &amp;lt;- Note start of a new page)&lt;BR /&gt;&lt;BR /&gt;So something mapped 417792 bytes (51 Alpha pages) after the address space that you mapped the first time.&lt;BR /&gt;&lt;BR /&gt;237772800 bytes (29025 Alpha Pages) mapped first time&lt;BR /&gt;237772800 bytes (29025 Alpha Pages) mapped second time&lt;BR /&gt;&lt;BR /&gt;Are you mapping different global sections each time through?  If not, then why are you deleting the virtual address space, just to remap it? If it is a different global section, but every global section is the same size, then clear the SEC$M_EXPREG after the map it the first time, and just reuse the same address space that got returned the first time.  If they are not all the same size, then you have a problem.  You will have to allocate enough for the largest global section, and just reuse the space starting at the same base address.&lt;BR /&gt;&lt;BR /&gt;Jon</description>
      <pubDate>Wed, 20 Feb 2008 09:36:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147552#M14205</guid>
      <dc:creator>Jon Pinkley</dc:creator>
      <dc:date>2008-02-20T09:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: P0 space of memory leak</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147553#M14206</link>
      <description>in $CRMPSC you used, but failed to tell us about, the flag EXPREG and did not specify an exact address range. Correct?&lt;BR /&gt;So OpenVMS grows the end of P0 VA to accomodate the section.&lt;BR /&gt;The $DELTVA now unmaps the section freeing the address space but openVMS does not know whether the program intends to re-use that address range to map something else later&lt;BR /&gt;&lt;BR /&gt;Rule: $DELTVA will reduce (shrink) the P0 VA end IF, and ONLY IF, the deltva range ends at the end... because in that case a future remap can always be accomodated.&lt;BR /&gt;&lt;BR /&gt;To verify this do (F$ | SYS$) GETJPI for FREP0VA&lt;BR /&gt;&lt;BR /&gt;What might have allocated memory after your section?&lt;BR /&gt;- LIB$GETVM / malloc. Workaround: pre-malloc / getvm all of what the program is expected to need in most circumstances, then immedaitly return for the program&lt;BR /&gt;- RMS internal structures (buffers, ifab, irab..). Woraround: increase SYSGEN IMGIOCNT and.or LINK with the IOSEGMENT option large enough for most usage&lt;BR /&gt;&lt;BR /&gt;- RMS global buffers and file statistics blocks. They suffer from the same creep. Fixed in OpenVMS 8.2 where RMS starts to remember the sections = address ranges used.&lt;BR /&gt;&lt;BR /&gt;So... the program may need to learn to remember some VA ranges.&lt;BR /&gt;&lt;BR /&gt;Duncan, I believe that in the problem you reference the DELTVA and FREPoVA does nto play a role.&lt;BR /&gt;&lt;BR /&gt;Hope this helps some,&lt;BR /&gt;Hein van den Heuvel (at gmail dot com)&lt;BR /&gt;HvdH Performance Consulting&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Feb 2008 12:27:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147553#M14206</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-02-20T12:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: P0 space of memory leak</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147554#M14207</link>
      <description>ajaydec,&lt;BR /&gt;&lt;BR /&gt;  Since you don't have complete control over all allocations in P0 space, you can't predict how your $MGBLSC and $DELTVA will interact with the rest of virtual address space. As Hein has suggested, your intention won't work unless the VA you're deleting remains at the end of P0 space.&lt;BR /&gt;&lt;BR /&gt;  It may be better to allocate a chunk of P0 space large enough for your largest expected requirement, then map the global sections as required, reusing the same address space. &lt;BR /&gt;&lt;BR /&gt;  Alternatively, move the section into P2 space using $MGBLSC_64 and $DELTVA_64 (though I think I'd leave out the $DELTVA part, as it just makes things more complicated, and you're going to recreate the space immediately anyway).</description>
      <pubDate>Thu, 21 Feb 2008 00:00:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147554#M14207</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2008-02-21T00:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: P0 space of memory leak</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147555#M14208</link>
      <description>If it were not feasible to manage this without mapping and unmapping (and assuming you can't simply reserve and overwrite the same virtual range), I'd consider moving to a small herd of server processes, and away from virtual memory mapping.  Keep a pool of server processes around as needed, communicate (via file or shared memory or mailbox or network or lock value block or ICC or whatever), and clean out virtual memory as required by cleaning out processes with $delprc or $forcex.&lt;BR /&gt;&lt;BR /&gt;Moving to processes (and a network) means you can incrementally expand or contract capacity.</description>
      <pubDate>Thu, 21 Feb 2008 02:24:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/p0-space-of-memory-leak/m-p/4147555#M14208</guid>
      <dc:creator>Hoff</dc:creator>
      <dc:date>2008-02-21T02:24:23Z</dc:date>
    </item>
  </channel>
</rss>

