Thanks Roberto,
what does heap reserve mean for example, is it some preallocated memory space when application starts up?
Thanks,
Petr
Hi,
I've been added the EXE_PE_GetHeapReserve(), EXE_PE_GetHeapCommit(), EXE_PE_GetStackReserve() and EXE_PE_GetStackCommit functions to the EXE module.
You'll find this update in the next ThinBasic release.
Here is a test script:
[code=thinbasic] '---------------------------------------------------------------------------------
'---ThinBASIC needed modules
'---------------------------------------------------------------------------------
USES "LL"
USES "EXE"
USES "FILE"
uses "Console"
'---------------------------------------------------------------------------------
'---Global variables
'---------------------------------------------------------------------------------
GLOBAL nFiles as long
global nSkippedFiles as long
GLOBAL sTime as string
global geStackR as ext
global geStackC as ext
global geHeapR as ext
global geHeapC as ext
%MY_MAXPATH = 125
%OFN_PATHMUSTEXIST = &H00000800
%OFN_FILEMUSTEXIST = &H00001000
SUB ProcessFile(lDir AS STRING, sFileMask as string)
LOCAL Count AS LONG
LOCAL FileName AS STRING
LOCAL pList AS LONG
LOCAL nItems AS LONG
local eStackR as ext
local eStackC as ext
local eHeapR as ext
local eHeapC as ext
pList = DIR_LIST(lDir, sFileMask, %FILE_NORMAL OR %FILE_HIDDEN OR %FILE_SYSTEM OR %FILE_ADDPATH)
nItems = LL_Count(pList)
IF nItems > 0 THEN
FOR Count = 1 TO nItems
INCR nFiles
FileName = LL_GetItem(pList, Count)
eStackR = EXE_PE_GetStackReserve(FileName)
' Skip some unpleasant files
if eStackR < 0 then
incr nSkippedFiles
else
eStackC = EXE_PE_GetStackCommit(FileName)
eHeapR = EXE_PE_GetHeapReserve(FileName)
eHeapC = EXE_PE_GetHeapCommit(FileName)
geStackR += eStackR
geStackC += eStackC
geHeapR += eHeapR
geHeapC += eHeapC
console_writeLine(Lset$(Filename, %MY_MAXPATH) & ":" & hex$(eStackR,6) & " " & hex$(eStackC, 6) & " " & hex$(eHeapR, 6) & " " & Hex$(eHeapC, 6))
end if
NEXT
END IF
END SUB
FUNCTION ListDir(sDir AS STRING, sDirMask as string, sFileMask as string) AS LONG
LOCAL Count AS LONG
LOCAL Item AS STRING
LOCAL pList AS LONG
LOCAL nItems AS LONG
LOCAL CurrentRow AS LONG
LOCAL TFS AS QUAD
pList = DIR_LIST(sDir, sDirMask, %FILE_Subdir OR %FILE_HIDDEN OR %FILE_ADDPATH)
nItems = LL_Count(pList)
IF nItems > 0 THEN
FOR Count = 1 TO nItems
Item = LL_GetItem(pList, Count)
CurrentRow = nFiles
TFS = ProcessFile(Item, sFileMask)
INCR nFiles
ListDir(Item, sDirMask, sFileMask)
NEXT
END IF
END FUNCTION
'-------------------------------------------------------------------------
'Main Program
'-------------------------------------------------------------------------
sub Main()
DIM T1 as long
T1 = TIMER
console_writeLine(Lset$(" FILENAME", 125) & " STACK HEAP")
console_writeLine(string$(%MY_MAXPATH, " ") & " RESERVE COMMIT RESERVE COMMIT")
ListDir("c:\windows\", "*.*", "*.EXE")
sTime = FORMAT$(Timer - T1, "#0.00000")
console_writeLine("TOTAL TIME (Secs): " & sTime)
console_writeLine("FILE SCANNED: " & str$(nFiles))
console_writeLine(Lset$("MEAN VALUES: ", %MY_MAXPATH) & ":" & hex$(geStackR/(nFiles - nSkippedFiles),6) & " " & hex$(geStackC/(nFiles - nSkippedFiles), 6) & " " & hex$(geHeapR/(nFiles - nSkippedFiles), 6) & " " & Hex$(geHeapC/(nFiles - nSkippedFiles), 6))
end sub
'-------------------------------------------------------------------------
'Start
'-------------------------------------------------------------------------
CALL Main()[/code]
Regards,
Roberto
http://www.thinbasic.com
Thanks Roberto,
what does heap reserve mean for example, is it some preallocated memory space when application starts up?
Thanks,
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Yes Petr, more precisely:
SizeOfStackReserve is the amount of virtual memory to reserve for the initial thread's stack, however not all of this memory is committed but only the amount specified by the SizeOfStackCommit field. For example this field is what PB fills with the value specified after the #STACK metastatement.
SizeOfStackCommit is the amount of memory initially committed for the initial thread's stack.
SizeOfHeapReserve is the amount of virtual memory to reserve for the initial process heap. This heap's handle can be obtained by calling GetProcessHeap. Like as for the stack not all of this memory is committed but only the amount specified by the SizeOfHeapCommit field. Recently I had some problems with the process heap in ThinAir.
SizeOfHeapCommit is the amount of memory initially committed in the process heap.
Roberto
http://www.thinbasic.com
Thanks for the udate Roberto.
Thanks for the update Roberto!
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Bookmarks