Does the datasection stay in the memory for all the time while a program is running
Does the datasection stay in the memory for all the time while a program is running
Hi,
I hope I find the right words: When working with a datasection I can access stored values (like a long or something) the same way I would access it within a memorysection allocated with AllocateMemory(). Does this mean all the stuff from the datasection is in my RAM while my program is running? If so, can I free this memory (and of course lose access) or is this counterproductive?
I hope I find the right words: When working with a datasection I can access stored values (like a long or something) the same way I would access it within a memorysection allocated with AllocateMemory(). Does this mean all the stuff from the datasection is in my RAM while my program is running? If so, can I free this memory (and of course lose access) or is this counterproductive?
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: Does the datasection stay in the memory for all the time while a program is running
It is persistent, and does not go away. I have never tried, but doubt you can free it. that would be modifying an executable, and most operating systems frown upon that.
Re: Does the datasection stay in the memory for all the time while a program is running
Nonono, I don't mean altering the executable. I don't want do lose my resources. I just mean whether it's always loaded into the ram or when it's needed. I can use the addresses, like ?MyAdress, like normal addresses, so I assume it's always in the ram, whenever my program runs. This means that I maybe use some ram for things I don't need, like an embedded picture, that is loaded via CatchImage(#PB_Any,?MyAddress), but I can't remove the memory where the picture is loaded from. Do you understand what I mean? this sounds like a waste of ram on longterm sight (if I use a big datasection instead of standalone files).
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: Does the datasection stay in the memory for all the time while a program is running
Yes it stays in memory but you can also write to a datasection while the exe is running which can be useful if you want to dynamically change parameters or state while the program runs.
-
- Enthusiast
- Posts: 544
- Joined: Wed Sep 25, 2019 10:18 am
Re: Does the datasection stay in the memory for all the time while a program is running
Code: Select all
; Datasection Section
*ptr.Byte=?Start
*ptr\b=49
; ! pb_data[0]=48;
Read.b i
Read.b j
Read.s s.s
SetClipboardText(Str(i)+" "+Str(j)+" "+s)
DataSection
Start:
Data.b 47,11
Data.s "Hello Universe"
EndDataSection
; C Backend:
; unsigned char pb_data[] = {47,11
; ,0x48,0x0,0x65,0x0,0x6C,0x0,0x6C,0x0,0x6F,0x0,0x20,0x0,0x55,0x0,0x6E,0x0,0x69,0x0,0x76,0x0,0x65,0x0,0x72,0x0,0x73,0x0,0x65,0x0,0,0
; };
; ASM Backend
; section '.data' Data readable writeable
; l_start:
; PB_DataSectionStart:
; db 47,11
; dw 72,101,108,108,111,32,85,110,105,118,101,114,115,101,0
; SYS_EndDataSection:
; x64dbg
; Adresse=000000013FF05000
; Größe=0000000000001000
; Name=".data"
; Inhalt der Auswahl=Initialisierte Daten
; Typ=IMG
; Aktueller Zugriff=-RW--
; Zugriff (beim Erstellen)=ERWC-
; 49 11 Hello Universe
Please ask your questions, because switch on the cognition apparatus decides on the only known life in the universe.Wersten :DDüsseldorf NRW Germany Europe Earth Solar System Flake Bubble Orionarm
Milky Way Local_Group Virgo Supercluster Laniakea Universe
Milky Way Local_Group Virgo Supercluster Laniakea Universe
Re: Does the datasection stay in the memory for all the time while a program is running
Well ok, thanks for the answers, I think I understand now.
So, I think it would be a good thing to be able to flush the data/free it. Like, if I have a lot of pictures in my code, load them and the I don't need the entire datasecrion anymore. Is this something for the wishlist or not? I don't like wasting resources.
So, I think it would be a good thing to be able to flush the data/free it. Like, if I have a lot of pictures in my code, load them and the I don't need the entire datasecrion anymore. Is this something for the wishlist or not? I don't like wasting resources.
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
- NicTheQuick
- Addict
- Posts: 1224
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: Does the datasection stay in the memory for all the time while a program is running
On the one hand the data within the datasection is accessible inside your application as it would be a normal memory section. But usually it will not compromise all your RAM if the datasection is huge. At first it will be file mapped (virtual memory) and only loaded into you physical memory when it gets accessed. And I would assume that your operating system will swap it to virtual memory again if you do not access it over a longer period and other processes need RAM.
Source: https://stackoverflow.com/questions/279 ... nto-memory
Source: https://stackoverflow.com/questions/279 ... nto-memory
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: Does the datasection stay in the memory for all the time while a program is running
It doesn't make sense as a wishlist request. You already have the choice of either putting something in a DataSection to be in memory while your program runs (and duplicated if you 'catch' them) or you load and free then as needed.jacdelad wrote: ↑Mon Nov 22, 2021 11:48 pmSo, I think it would be a good thing to be able to flush the data/free it. Like, if I have a lot of pictures in my code, load them and the I don't need the entire datasecrion anymore. Is this something for the wishlist or not? I don't like wasting resources.
Last edited by Demivec on Tue Nov 23, 2021 8:02 am, edited 1 time in total.
-
- Enthusiast
- Posts: 544
- Joined: Wed Sep 25, 2019 10:18 am
[Done] Re: Does the datasection stay in the memory for all the time while a program is running
Code: Select all
; DLLImage
ProcedureDLL.i startdata()
ProcedureReturn ?start
EndProcedure
DataSection
Start:
IncludeBinary "PureBasic.bmp" ; Please adapt.
EndDataSection
CompilerIf #PB_Compiler_ExecutableFormat<>#PB_Compiler_DLL
CompilerError "Please use Compiler Option Executable Format DLL and Compiler Executable generate."
CompilerEndIf
Code: Select all
; catchImageDLL
If OpenLibrary(0, "dllImage.dll")
CatchImage(0,CallFunction(0,"startdata"))
CloseLibrary(0) ; And free memory from dllImage.dll.
OpenWindow(0, 0, 0, 245, 105, "CatchImageDLL", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ImageGadget(0, 10, 10, 100, 83, ImageID(0))
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
Else
MessageRequester("Error","Can not find dllImage.dll.")
EndIf
Re: Does the datasection stay in the memory for all the time while a program is running
That makes sense, but if I want to make a program that only consists of one file I feel a bit limited. I don't like putting resources into the folder so everyone can manipulate them. Stupid users deleting something and it's not working anymore. One file, that's all. Maybe I have to rethink my concept or live with it.
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
- NicTheQuick
- Addict
- Posts: 1224
- Joined: Sun Jun 22, 2003 7:43 pm
- Location: Germany, Saarbrücken
- Contact:
Re: Does the datasection stay in the memory for all the time while a program is running
If users do that then it's their fault, not yours.jacdelad wrote: ↑Tue Nov 23, 2021 9:47 am That makes sense, but if I want to make a program that only consists of one file I feel a bit limited. I don't like putting resources into the folder so everyone can manipulate them. Stupid users deleting something and it's not working anymore. One file, that's all. Maybe I have to rethink my concept or live with it.
Also if you install your software properly inside the "Program Files" directory on Windows or in /usr/local/bin on Linux and libraries and shares in /var/lib and /usr/share then there should be no problem unless the user decides to become root.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Re: Does the datasection stay in the memory for all the time while a program is running
It's hard to tell my boss "Oh no, X deleted a file again and Tool Y does not run anymore.". That's why I decided to put it all in one file.
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: Does the datasection stay in the memory for all the time while a program is running
You could use somethig like: https://enigmaprotector.com/en/aboutvb.html to encapsulate all the files in one exe
Re: Does the datasection stay in the memory for all the time while a program is running
Thanks for the idea, but I think that would an overkill. Beside that I have to purchase it, my problem is just about a few MBs of ram and also nothing to hide.
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: Does the datasection stay in the memory for all the time while a program is running
ezpack, compresses files to a pack which you can then catch from memory without writing them to disk
viewtopic.php?f=27&t=52586
viewtopic.php?f=27&t=52586