Workaround FreeString Resources (Set to Nothing)
Re: Workaround FreeString Resources (Set to Nothing)
Link to bug-reports
viewtopic.php?f=4&t=71568&start=0#p531589
viewtopic.php?f=4&t=71568&start=15#p538347
viewtopic.php?f=4&t=71568&start=0#p531589
viewtopic.php?f=4&t=71568&start=15#p538347
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: Workaround FreeString Resources (Set to Nothing)
Are you trolling?skywalk wrote:Yes, so I am asking why Mijikai says PB strings are broken?
Re: Workaround FreeString Resources (Set to Nothing)
No, he hadn't been involved with it before.Mijikai wrote:Are you trolling?skywalk wrote:Yes, so I am asking why Mijikai says PB strings are broken?
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: Workaround FreeString Resources (Set to Nothing)
@Mijikai, Surely not. I thought you were because you trash the entire v571 for a small bug? It does not cause leaks, only inefficient with memory. I cannot wait for the release with no bugs!
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Workaround FreeString Resources (Set to Nothing)
Not quite...
What didn't cause any problems with PB v5.6x, leads to a memory leak with PB v5.7x.
What didn't cause any problems with PB v5.6x, leads to a memory leak with PB v5.7x.
Code: Select all
Structure sFoo
iVal.i
sVal.s
EndStructure
*mem.sFoo = AllocateMemory(SizeOf(sFoo))
*mem\sVal = "Hello"
;
; ...
;
*mem\sVal = #Null$
FreeMemory(*mem)
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: Workaround FreeString Resources (Set to Nothing)
haha, but we go in circles
You are clearing memory with a loosely documented step(#Null$). I only found it mentioned here in the manual with no examples.mk-soft wrote:If you do everything right, there will be no memory leakage
- AllocateStructure -> FreeStructure
- AllocateMemory -> ClearMemory -> FreeMemory.
Curious? Why not stick with AllocateStructure->FreeStructure to avoid this issue?manual wrote:There are two special constants for strings:
#Empty$: represents an empty string (exactly the same as "")
#Null$ : represents an null string. This can be used for API
functions requiring a null pointer to a string, or to really free a string.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Re: Workaround FreeString Resources (Set to Nothing)
Depends on the task if you need it that way.skywalk wrote: Curious? Why not stick with AllocateStructure->FreeStructure to avoid this issue?
It is not always possible to work with AllocateStructure or to rebuild the whole structure every time only to set a string to Nothing for API calls.
It should work as described in the description.
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: Workaround FreeString Resources (Set to Nothing)
Josh Link: viewtopic.php?f=4&t=71568&start=15#p541135
Set String to Nothing
ASM-Code is ok
Set String to Nothing
Code: Select all
Macro Nothing
"!_PB_NullConstant_!"
EndMacro
Define s.s
s = "Global Hello World"
Debug s
Debug "Adress to String = " + @s
s = #Null$
Debug "Adress to String (#Null$) = " + @s ; <- Must be 0.
s = Nothing
Debug "Adress to String (Nothing) = " + @s ; <- Must be 0.
Structure udtFoo
iVal.i
sVal.s
EndStructure
a.udtFoo
a\iVal = 100
a\sVal = "Structure Hello World"
Debug a\sVal
Debug "Adress to String = " + PeekI(@a+OffsetOf(udtFoo\sVal))
Debug a\sVal
a\sVal = Nothing
Debug "Adress to String (Nothing) = " + PeekI(@a+OffsetOf(udtFoo\sVal))
Debug a\sVal
...
; s = Nothing
XOR rsi,rsi
LEA rdi,[v_s]
CALL _SYS_FastAllocateStringFree4
...
; a\sVal = Nothing
XOR rsi,rsi
LEA rdi,[rbp+8]
CALL _SYS_FastAllocateStringFree4
...
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: Workaround FreeString Resources (Set to Nothing)
So basically just the constant is wrong?
Sounds like good news.
Sounds like good news.
Re: Workaround FreeString Resources (Set to Nothing)
This is why I hate this approach.
Just make a function that clears strings and be done with this.
Just make a function that clears strings and be done with this.
Code: Select all
EnableExplicit
#Null$ = "!_PB_NullConstant_!"
Debug #Null$ ;BAD Design if constant has hidden meaning?
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum