Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #9474
| Message-ID | <nkdrbu.3l4.1@xsharp.info> (permalink) |
|---|---|
| Subject | Re: SetMaxDynSize VS SetMaxThreadDynSize |
| Newsgroups | comp.lang.clipper.visual-objects |
| References | <nk9egt$fha$1@news.albasani.net> |
| From | Robert van der Hulst <robert@xsharp.eu> |
| Organization | XSharp |
| Date | 2016-06-22 11:04 +0200 |
Jim,
SetMaxDynSize sets the size for the main thread.
And there is really no "optimal value". What you should keep in mind is:
- VO will use static memory for a lot of things, such as the Symbol
table, Runtime Class information etc. MemTotal() tells you how much is
allocated at a certain moment.
- Whatever you allocate for dynamic memory will be allocated twice. VO
works with 2 dynamic memory pages (one of these is active)
In apps that may require a lot of memory I call a method from a timer on
the shell where I am keeping track of the used and free memory. See below.
At startup I initialize an initial amount of memory
SetMaxDynSize(0x4000000) // Total 64 Mb per Dynamic Page = 128 Mb total
DynSize(500) // = Preallocate 500 pages of 64 Kb
from the timer on the shell I call this method. You may use it at your
own risk <g>.
METHOD CheckDynMemSize() CLASS MySHELL
LOCAL nActualSizeAllocated AS DWORD
LOCAL nActualSizeused AS DWORD
LOCAL nActualSizeMax AS DWORD
LOCAL nMaxDynAllowed AS DWORD
LOCAL nMaxPages AS DWORD
LOCAL nNewSizeInPages AS DWORD
LOCAL nNewSizeInBytes AS DWORD
LOCAL nUsed, nMax, nCheck AS DWORD
STATIC lBusy AS LOGIC
IF ! lBusy
lBusy := TRUE
// Check RegisterAxit
nUsed := Memory(MEMORY_REGISTERAXIT)
nMax := SetMaxRegisteredAxitMethods(0)
nCheck := DWORD(MulDiv(LONG(nMax), 90, 100))
IF nUsed > nCheck // > 90%
DebOut("Approaching RegisterAxit limit, COLLECTFORCED")
Sleep(2000)
CollectForced()
nUsed := Memory(MEMORY_REGISTERAXIT)
IF nUsed > nCheck
SetMaxRegisteredAxitMethods(DWORD(nMax * 1.5)) // 50% more
ENDIF
ENDIF
// Check RegisterKid
nUsed := Memory(MEMORY_REGISTERKID)
nMax := SetMaxRegisteredKids(0)
nCheck := DWORD(MulDiv(LONG(nMax), 90, 100))
IF nUsed > nCheck // > 90%
DebOut("Approaching RegisterKid limit, COLLECTFORCED")
Sleep(2000)
CollectForced()
nUsed := Memory(MEMORY_REGISTERKID)
IF nUsed > nCheck
SetMaxRegisteredKids(DWORD(nMax * 1.5)) // 50% more
ENDIF
ENDIF
// Check KidStackSize
nUsed := Memory(MEMORY_STACKKID)
nMax := SetKidStackSize(0)
nCheck := DWORD(MulDiv(LONG(nMax), 90, 100))
IF nUsed > nCheck // > 90%
DebOut("Approaching KidStack limit, COLLECTFORCED")
Sleep(2000)
CollectForced()
nUsed := Memory(MEMORY_STACKKID)
IF nUsed > nCheck
SetKidStackSize(DWORD(nMax * 1.5)) // 50% more
ENDIF
ENDIF
nMaxDynAllowed := 1024*1024*128
nMaxPages := nMaxDynAllowed /0x10000
nActualSizeAllocated := DynInfoSize() * 0x10000
// DyInfoSize returns the number of 64Kb pages
nActualSizeused := DynInfoUsed()
nActualSizeMax := SetMaxDynSize(0)
// When we have used 80 % or more of the allocated memory,
// then it is time to allocate some more pages
IF nActualSizeused > nActualSizeAllocated * 0.80
CollectForced()
nActualSizeused := DynInfoUsed()
IF nActualSizeused > nActualSizeAllocated * 0.80
nNewSizeInPages := DynInfoSize() +25
nNewSizeInBytes := nNewSizeInPages * 0x10000
// Make sure that we do not allocate more then the
DynInfoMax.
// If we reach that, then we need to set the max to a
higher number
IF nNewSizeInBytes >= nActualSizeMax
IF nNewSizeInPages >= nMaxPages
// Allocate some extra memory just to be sure
SetMaxDynSize(nMaxDynAllowed)
ELSE
// Allocate some extra memory just to be sure
SetMaxDynSize(nNewSizeInBytes)
DynSize(nNewSizeInPages-1)
ENDIF
ELSE
DynSize(nNewSizeInPages)
ENDIF
ENDIF
ENDIF
lBusy := FALSE
ENDIF
RETURN NIL
Robert
> I know the default for the SetMaxDynSize() and SetMaxThreadDynSize() is
> 16MB.
>
> The help file says about SetMaxThreadDynSize() that it is used a NEW
> thread, what about the running app?
>
> Is this redundant and SetMaxDynSize() is what is only needed if I am not
> using threads ?
>
> Jim
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
SetMaxDynSize VS SetMaxThreadDynSize "Jim" <nospam@example.com> - 2016-06-20 15:00 -0400
Re: SetMaxDynSize VS SetMaxThreadDynSize "Jim" <nospam@example.com> - 2016-06-22 01:47 -0400
Re: SetMaxDynSize VS SetMaxThreadDynSize "Arne Ortlinghaus" <Arne.Ortlinghaus@acs.it> - 2016-06-22 10:54 +0200
Re: SetMaxDynSize VS SetMaxThreadDynSize Robert van der Hulst <robert@xsharp.eu> - 2016-06-22 11:04 +0200
Re: SetMaxDynSize VS SetMaxThreadDynSize "Arne Ortlinghaus" <Arne.Ortlinghaus@acs.it> - 2016-06-22 17:35 +0200
Re: SetMaxDynSize VS SetMaxThreadDynSize "Jim" <nospam@example.com> - 2016-06-22 12:17 -0400
Re: SetMaxDynSize VS SetMaxThreadDynSize "Wolfgang Riedmann" <wriedmann@gmail.com> - 2016-06-23 04:08 +0200
csiph-web