How to have the memory size
How to have the memory size
How can I have the memory size in another way than using this api command :
GlobalSize_(mem)
Because it doesn't seem to work perfectly with the new memory commands of the beta 1.89
GlobalSize_(mem)
Because it doesn't seem to work perfectly with the new memory commands of the beta 1.89
-
freedimension
- Enthusiast

- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
Code: Select all
Procedure GetFreeRAM()
Info.MEMORYSTATUS
Info\dwLength = SizeOf(MEMORYSTATUS)
GlobalMemoryStatus_(@Info)
ProcedureReturn Info\dwAvailPhys
EndProcedure
Procedure GetTotalRAM()
Info.MEMORYSTATUS
Info\dwLength = SizeOf(MEMORYSTATUS)
GlobalMemoryStatus_(@Info)
ProcedureReturn Info\dwTotalPhys
EndProcedurethanks, but I'm not searching for that (I certainly forgot to tell something, sorry
).
What I want is to do that :
mem=AllocateMemory(12)
mem=ReallocateMemory(mem,16)
For example, and now :
size=functionwhichreturnthesize(mem)
size is here supposed to be 16.
And I don't want to use the Globalsize function.
What I want is to do that :
mem=AllocateMemory(12)
mem=ReallocateMemory(mem,16)
For example, and now :
size=functionwhichreturnthesize(mem)
size is here supposed to be 16.
And I don't want to use the Globalsize function.
-
freedimension
- Enthusiast

- Posts: 613
- Joined: Tue May 06, 2003 2:50 pm
- Location: Germany
- Contact:
-
dontmailme
- Enthusiast

- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
Quick and Dirty.....
Code: Select all
mem=AllocateMemory(12)
mem=ReAllocateMemory(mem,16)
hndl=getprocessheap_()
Debug heapsize_(hndl,0,mem)
Paid up PB User !
-
dontmailme
- Enthusiast

- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
-
dontmailme
- Enthusiast

- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
Yes I know the GetProcessHeap() function. But this function returns the heap, that
Windows has created for the process. PB however creates a seperate one.
GetProcesHeap() is intended to be used if you only need a few memory blocks,
and don't want to create an extra heap for your application.
See this:
I guess this is an undocumented feature of windows. (that you can use 2 different heap handles and both work)
But i wouldn't count on it, who knows how different windows versions handle this.
Better use the above PB_Heap() procedure.
Timo
Windows has created for the process. PB however creates a seperate one.
GetProcesHeap() is intended to be used if you only need a few memory blocks,
and don't want to create an extra heap for your application.
See this:
Code: Select all
Procedure PB_Heap()
!mov eax, dword [_PB_MemoryBase] ; this is the real PB memory heap
ProcedureReturn
EndProcedure
Debug GetProcessHeap_()
Debug PB_Heap()But i wouldn't count on it, who knows how different windows versions handle this.
Better use the above PB_Heap() procedure.
Timo
quidquid Latine dictum sit altum videtur
-
dontmailme
- Enthusiast

- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
Well this produces the same end-result.......
Maybe PB requests memory from Windoze, reserves some for itself..... and then allocates from that point onwards....... so we are talking about the same memory at the end of the day..... and two different ways of acessing it..... through PB's 'stack' or through API.....
??!! Maybe Fred can answer this ??
Code: Select all
Procedure PB_Heap()
!MOV eax, dword [_PB_MemoryBase] ; this is the real PB memory heap
ProcedureReturn
EndProcedure
mem=AllocateMemory(12)
mem=ReAllocateMemory(mem,16)
PB_hndl=PB_Heap()
hndl=getprocessheap_()
Debug heapsize_(hndl,0,mem)
Debug heapsize_(PB_hndl,0,mem)
??!! Maybe Fred can answer this ??
Paid up PB User !
That's what i am telling you. It produces the same end result.Well this produces the same end-result.......
But this is a not documented behaviour. (of Windows), so you can't
be 100% sure of it.
See, there you have it. It doesn't always work.Polo wrote:Fred should do himself a function that return memory size, because, I don't know why, but in some cases, the api command doesn't work and return -1
Maybe you should read a little documentation on memory management... what you say makes no senseMaybe PB requests memory from Windoze, reserves some for itself..... and then allocates from that point onwards....... so we are talking about the same memory at the end of the day..... and two different ways of acessing it..... through PB's 'stack' or through API.....
PB's memory management is a direct wrapper for the windows API here,
there is nothing misterious going on.
It's just a M$ *feature*, nothing more.
(I'd still stick with _PB_MemoryBase though.. just to be sure)
Timo
quidquid Latine dictum sit altum videtur
-
dontmailme
- Enthusiast

- Posts: 537
- Joined: Wed Oct 29, 2003 10:35 am
It does, see polo's corrected statementfreak wrote:Polo wrote:Fred should do himself a function that return memory size, because, I don't know why, but in some cases, the api command doesn't work and return -1freak wrote: See, there you have it. It doesn't always work.
I see no point, you obviously have read this and you don't understand this behaviour..... 8Ofreak wrote: Maybe you should read a little documentation on memory management... what you say makes no sense![]()
That must be why it works then !freak wrote: PB's memory management is a direct wrapper for the windows API here,
there is nothing misterious going on.
I think maybe Fred should comment on this as he obviously knows what he's doing
Paid up PB User !


