Feature Request 'SaveMemory' to Disk Drive
Feature Request 'SaveMemory' to Disk Drive
EG
FillMemory (*Memory , Size , Value)
SaveMemory (0 , *Memory , Size , "data.tmp")
That works with any size of memory and has no limits of any kind.
Even to take a snapshot of 32 Gigabytes of RAM or more...
All the best.
Thank You
FillMemory (*Memory , Size , Value)
SaveMemory (0 , *Memory , Size , "data.tmp")
That works with any size of memory and has no limits of any kind.
Even to take a snapshot of 32 Gigabytes of RAM or more...
All the best.
Thank You
Re: Feature Request 'SaveMemory' to Disk Drive
You programme something like that yourself
-1
Code: Select all
;-TOP
Procedure SaveMemory(*Memory, Size, FileName.s)
Protected r1, file, cnt
file = CreateFile(#PB_Any, FileName)
If file
cnt = WriteData(file, *Memory, Size)
CloseFile(file)
If cnt = Size
r1 = #True
EndIf
EndIf
ProcedureReturn r1
EndProcedure
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: Feature Request 'SaveMemory' to Disk Drive
If you put the parameter Size last you can make it optional and make it even easier. Leaving it could trigger MemorySize().
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Feature Request 'SaveMemory' to Disk Drive
mk-soft WriteData have 2GB limitmk-soft wrote: ↑Sun Jun 26, 2022 5:32 pm You programme something like that yourself-1Code: Select all
;-TOP Procedure SaveMemory(*Memory, Size, FileName.s) Protected r1, file, cnt file = CreateFile(#PB_Any, FileName) If file cnt = WriteData(file, *Memory, Size) CloseFile(file) If cnt = Size r1 = #True EndIf EndIf ProcedureReturn r1 EndProcedure
https://www.purebasic.fr/english/viewtopic.php?t=78697
thank you
Last edited by Simo_na on Sun Jun 26, 2022 10:54 pm, edited 1 time in total.
Re: Feature Request 'SaveMemory' to Disk Drive
Parameters for functions can be optional, so you can make the function easier in case you want to write a whole memory block to disk:
If you want to write the whole content of *Memory to disk, you don't need to specifiy Size.
Code: Select all
Procedure SaveMemory(*Memory, FileName.s, Size=-1)
Protected r1, file, cnt
file = CreateFile(#PB_Any, FileName)
If file
If Size = -1
Size = MemorySize(*Memory)
EndIf
cnt = WriteData(file, *Memory, Size)
CloseFile(file)
If cnt = Size
r1 = #True
EndIf
EndIf
ProcedureReturn r1
EndProcedure
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Feature Request 'SaveMemory' to Disk Drive
jacdelad,jacdelad wrote: ↑Mon Jun 27, 2022 4:56 am Parameters for functions can be optional, so you can make the function easier in case you want to write a whole memory block to disk:If you want to write the whole content of *Memory to disk, you don't need to specifiy Size.Code: Select all
Procedure SaveMemory(*Memory, FileName.s, Size=-1) Protected r1, file, cnt file = CreateFile(#PB_Any, FileName) If file If Size = -1 Size = MemorySize(*Memory) EndIf cnt = WriteData(file, *Memory, Size) CloseFile(file) If cnt = Size r1 = #True EndIf EndIf ProcedureReturn r1 EndProcedure
I can't figure out how to run your code, could you give me a complete real working example to save a size of 8 Gigs to file ?
Thank you
Re: Feature Request 'SaveMemory' to Disk Drive
Assuming you can allocate 8GB of memory:
Code: Select all
Procedure SaveMemory(*Memory, FileName.s, Size=-1)
Protected r1, file, cnt
file = CreateFile(#PB_Any, FileName)
If file
If Size = -1
Size = MemorySize(*Memory)
EndIf
cnt = WriteData(file, *Memory, Size)
CloseFile(file)
If cnt = Size
r1 = #True
EndIf
EndIf
ProcedureReturn r1
EndProcedure
*mem=AllocateMemory(8*1024*1024*1024)
If *mem
;Fill your memory with whatever you want to
save.s=SaveFileRequester("Save my 8GB of memory","Default.dat","Dat-Files|*.dat|All Files|*.*",0)
If save<>""
SaveMemory(*mem,save)
;SaveMemory(*mem,save,8*1024*1024*1024);Not needed if I save all data from *mem
EndIf
FreeMemory(*mem)
Else
MessageRequester("Error","Couldn't assign 8GB of memory. :(",#PB_MessageRequester_Error)
EndIf
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Re: Feature Request 'SaveMemory' to Disk Drive
Sorry but isn't don't work, the code generate a 0 byte file. Thank youjacdelad wrote: ↑Tue Jun 28, 2022 4:36 am Assuming you can allocate 8GB of memory:Code: Select all
Procedure SaveMemory(*Memory, FileName.s, Size=-1) Protected r1, file, cnt file = CreateFile(#PB_Any, FileName) If file If Size = -1 Size = MemorySize(*Memory) EndIf cnt = WriteData(file, *Memory, Size) CloseFile(file) If cnt = Size r1 = #True EndIf EndIf ProcedureReturn r1 EndProcedure *mem=AllocateMemory(8*1024*1024*1024) If *mem ;Fill your memory with whatever you want to save.s=SaveFileRequester("Save my 8GB of memory","Default.dat","Dat-Files|*.dat|All Files|*.*",0) If save<>"" SaveMemory(*mem,save) ;SaveMemory(*mem,save,8*1024*1024*1024);Not needed if I save all data from *mem EndIf FreeMemory(*mem) Else MessageRequester("Error","Couldn't assign 8GB of memory. :(",#PB_MessageRequester_Error) EndIf
Re: Feature Request 'SaveMemory' to Disk Drive
Yes Simo_na, I also get a 0 byte file.
I'm using PB 6.0 (x64) on a Windows 10 Pro machine.
- It was too lonely at the top.
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Re: Feature Request 'SaveMemory' to Disk Drive
- It was too lonely at the top.
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.10 LTS (x64) and Win Pro 11 (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Re: Feature Request 'SaveMemory' to Disk Drive
i've try with Win 11 and PB6, nothing change... 0 size file
Intel Core I9 11900KF
32 GB DDR4
Intel Core I9 11900KF
32 GB DDR4
Re: Feature Request 'SaveMemory' to Disk Drive
It also works for me on Windows 10 21H2 by allocating 1 Gb memory.
But if I allocate 2 Gb, In debug, it crashes on Line 8, WriteData : Invalid memory access.
I have 10Gb of free memory currently
But if I allocate 2 Gb, In debug, it crashes on Line 8, WriteData : Invalid memory access.
I have 10Gb of free memory currently