Showing same memory amount with while loop

[CmdletBinding()]
param()
Begin
{

$Totalmemory = (Get-WmiObject -Class Win32_operatingsystem).TotalVisibleMemorySize
#Get Live Memory Status
$FreeMem = ((Get-Counter -Counter "\memory\available mbytes" -MaxSamples 2 -SampleInterval 2 ).CounterSamples).CookedValue
$FinalFreemem = ((($FreeMem | Measure-Object -Minimum).Minimum)/1024).Tostring("#.###")
$meminGB = ($Totalmemory/1024) 
$FinalTotalmem = ($meminGB/1024).ToString("##.###")
$TotalFreeMemPerc = ($FinalFreemem/$FinalTotalmem)*100
}
Process
{
while($true)
{

if ($TotalFreeMemPerc -le 20)

{
    $TotalFreeMemPerc
    $Bindtest= 1..3 | % {(Test-NetConnection -ComputerName ("$env:COMPUTERNAME"+"."+"$env:USERDNSDOMAIN") -Port 636).TcpTestSucceeded}
    
    $Bindtest
    
if ($Bindtest -notcontains $false)
    {
    Write-Verbose -Message "Bind Successful"
    }
Else
    {
                    
    Write-Error "very bad"
   }}}}
    End
    {
    
    }

Could you please format your code as code? And what is your question?

Formatted that code & Memory is not changing while running . need to capture the live memory data.

$FreeMem is defined outside the loop, and never redefined. You are retrieving only the current value data from the sample at one point, and never accessing the counter again.

Thanks. Now that is working.