Author |
Topic: LBB (initial) memory usage (Read 557 times) |
|
tsh73
Full Member
member is offline
Gender:
Posts: 210
|
|
LBB (initial) memory usage
« Thread started on: Mar 20th, 2015, 07:34am » |
|
I wonder if I am the only person who consider that to be a problem. Since version 2.60, >> The amount of memory available has been increased to 500 Megabytes. But that looks like 500 Megabytes is grabbed on each start of a program. So, on my machine (I know it's old) with 1Gb RAM and Win XP, it works like this (looking at Process Explorer): Just after reboot (only big program running is Outlook) commit charge: current 684 700 limit 2 069 828 After starting EXE compiled with LBB: current 1 200 000 2nd exe: 1 720 000 3rd: 2 244 000 commit charge shows 99% That's all - any other attempts ends with "No room" error It just irks me that any small program eats up 500mb memory. With 100mb, I just did not bumped into this. What was the reason anyway? I have read that in LBB, one can use REDIM to get array of any size which memory allows.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: LBB (initial) memory usage
« Reply #1 on: Mar 20th, 2015, 09:20am » |
|
on Mar 20th, 2015, 07:34am, tsh73 wrote:But that looks like 500 Megabytes is grabbed on each start of a program. |
|
No, it's 500 Mbytes of virtual memory (address space), not real memory. I've just run a small executable compiled using LBB v3.00, and Task Manager is reporting that it is using 17.6 Mbytes of memory (Windows 8.1), which I don't think is too bad.
Edit: Just compiled a program consisting of the single statement wait. Task Manager reports 1.9 Mbytes memory usage.
Quote:What was the reason anyway? |
|
For improved compatibility with LB4.5, which reserves 1 Gbyte of virtual memory (compared with the 70 Mbytes or so of LB 4.04).
Richard.
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: LBB (initial) memory usage
« Reply #2 on: Mar 20th, 2015, 10:15am » |
|
Sixteen copies of the program running:
|
|
Logged
|
|
|
|
tsh73
Full Member
member is offline
Gender:
Posts: 210
|
|
Re: LBB (initial) memory usage
« Reply #3 on: Mar 20th, 2015, 10:29am » |
|
Ok, 16 copies - more then enough. So I'll say it's just sign of long overdue upgrade in my part. Please tell how much memory your machine has and what is the OS? EDIT I see the OS - Windows 8.1
|
« Last Edit: Mar 20th, 2015, 10:31am by tsh73 » |
Logged
|
|
|
|
Hans
New Member
member is offline
Gender:
Posts: 31
|
|
Re: LBB (initial) memory usage
« Reply #4 on: Mar 20th, 2015, 10:29am » |
|
It has something to do whith the way you retreive the amount of memory used. I use the code below since long in a number of LB apps. In LBB the result is always 500, but the Taskmanager gives much lower amounts, more believeble. That's why I've now included an extra if statement for LBB. Because in LBB one has almost infinite memory, it is not high on my prioritylist but I will have to look for another way to retreive the amount of memory.
Hans
Code:FUNCTION GetUsedMemory(byref ErrorMsg$)
'=returns the memory used by the current process
'returns -1 if an error is encountered
'the error message is stored in the submitted variable
ErrorMsg$ = ""
struct ProcessMemoryCounters, _
cb as ulong,_
PageFaultCount as ulong,_
PeakWorkingSetSize as ulong,_
WorkingSetSize as ulong,_
QuotaPeakPagedPoolUsage as ulong,_
QuotaPagedPoolUsage as ulong,_
QuotaPeakNonPagedPoolUsage as ulong,_
QuotaNonPagedPoolUsage as ulong,_
PagefileUsage as ulong,_
PeakPagefileUsage as ulong
ProcessMemoryCounters.cb.struct = len(ProcessMemoryCounters.struct)
open "psapi.dll" for dll as #psapi
calldll #kernel32, "GetCurrentProcess",hProcess as ulong
cb = len(ProcessMemoryCounters.struct)
calldll #psapi, "GetProcessMemoryInfo",_
hProcess as ulong,_
ProcessMemoryCounters as struct,_
cb as ulong,_
result as long
if result then
GetUsedMemory = ProcessMemoryCounters.PagefileUsage.struct
else
call GetLastError ErrorMsg$
GetUsedMemory = -1
end if
close #psapi
UsedMemory = GetUsedMemory/1000000 'convert to MB
if instr(version$,"LBB")<>1 then
if UsedMemory>65 then notice "Memory nearly full: "+using("####",UsedMemory)
end if
END FUNCTION
SUB GetLastError byref Message$
calldll #kernel32, "GetLastError", ErrorCode as ulong
dwFlags = _FORMAT_MESSAGE_FROM_SYSTEM
nSize = 1024
lpBuffer$ = space$(nSize); chr$(0)
dwMessageID = ErrorCode
calldll #kernel32, "FormatMessageA", _
dwFlags as ulong, _
lpSource as ulong, _
dwMessageID as ulong, _
dwLanguageID as ulong, _
lpBuffer$ as ptr, _
nSize as ulong, _
Arguments as ulong, _
result as ulong
Message$ = left$(lpBuffer$, result)
END SUB
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: LBB (initial) memory usage
« Reply #5 on: Mar 20th, 2015, 12:21pm » |
|
on Mar 20th, 2015, 10:29am, Hans wrote:It has something to do whith the way you retreive the amount of memory used. |
|
The problem is that both you and Anatoly are measuring the Commit Charge, which is the amount of memory a process has said it might use.
But this reserved address space does not actually use up real memory, until you create variables, arrays, structures, strings etc. to occupy it. In other words it doesn't reduce the memory available to other processes, which run in their own private address spaces.
This article has some interesting information. In particular read the section So what is “commit?”:
http://brandonlive.com/2010/02/21/measuring-memory-usage-in-windows-7/
Specifically it warns that if you disable your page file then Windows will reserve real memory rather than virtual memory, and then LBB really will gobble up 500 Mbytes of RAM!
Richard.
|
|
Logged
|
|
|
|
|