Author Topic: Clean Memory - issue  (Read 23065 times)

0 Members and 1 Guest are viewing this topic.

makinero

  • Guest
Clean Memory - issue
« on: December 24, 2015, 08:58:43 am »
Clean Memory - there is a tool that "aggressively" (WashedMemory & FlushCache)?

For me it works (eg. releases 2GB of RAM), but....

The data are safe?
I mean,1.  it does not cause application crashes?
2. or does not clean BUFFER -in hard drive?
or 3. (I mean that nothing is allocated) ???


« Last Edit: December 24, 2015, 09:04:20 am by makinero »

Offline Willy2

  • Hero Member
  • *****
  • Join Date: Oct 2011
  • Posts: 1165
  • Karma: 18
    • View Profile
Re: Clean Memory - issue
« Reply #1 on: December 28, 2015, 07:09:43 am »
- I assume you mean the "Clean memory" feature that reduces memory usage before the repairs are run ?
- There's a "stand alone" program available at http://www.pcwintech.com/cleanmem
- The program uses a feature that kicks Windows' memory management into action. Since it uses a Windows feature it perfectly safe to use. I have it running all the time on my Win 7 system. Never had any problems.
- The advantage of reducing memory usage this way is that it also reduces disk I/O and that's comparitively very slow. So, it increases overall system performance.

makinero

  • Guest
Re: Clean Memory - issue
« Reply #2 on: December 31, 2015, 10:23:30 am »
Willy2 -
see this webpage:
http://chadaustin.me/flushmem/
http://stackoverflow.com/questions/763159/should-i-bother-detecting-oom-out-of-memory-errors-in-my-c-code

I tested the application and it is true that running applications may be crash (example: WebBrowser etc.)
Preview:
Fair warning: most programs don’t handle running out of memory, so don’t be surprised if flushmem.exe causes running programs to crash, potentially losing your data.
« Last Edit: December 31, 2015, 10:43:53 am by makinero »

Offline Willy2

  • Hero Member
  • *****
  • Join Date: Oct 2011
  • Posts: 1165
  • Karma: 18
    • View Profile
Re: Clean Memory - issue
« Reply #3 on: January 07, 2016, 04:33:55 pm »
- On the Cleanmem support forum there was a similar OOM problem as well. But Cleanmem wasn't causing the problem.
http://forums.pcwintech.com/index.php/topic,5440.0.html

As said in this thread Cleanmem only reduces the "In Use" part of the memory, that part is turned into "Modified". (See "Resource Monitor", memory tab) and from there Windows takes over.

- Some programs can be a REAL "Pain in the a**". I came across a 32 bit program that was run on a 64 bit system with 12 GB of memory but the program would crash when it reached the upper limit of only 4 GB (the memory limit of a 32 bit system).

- I have a backup program to back up my HD but after having used that program my system has turned into one giant snail. Turns out that the file cache was VERY large (GBs) and occupied the entire memory (and more ???). Cleanmem "kills the snail" by collapsing the file cache.

- When I read the info on "Flushmem" then it looks like that this program uses a very different way of "cleaning caches", i.e. allocating as much memory as possible. That means "Flushmem" uses the "SetWorkingSet" API instead of the "EmptyWorkingSet" API. Using "SetWorkingSet" is what causes "a hiccup". No wonder, "Flushmem" can/will cause large problems.
« Last Edit: January 07, 2016, 04:55:18 pm by Willy2 »

makinero

  • Guest
Re: Clean Memory - issue
« Reply #4 on: January 08, 2016, 04:43:56 am »
Clean Memory - This is probably overlay on the original applications sysinternals . . Popularly known as Flushing Metafile
 a long time I use 2 sysinternals applications run from the executable file BAT and it works the same way . .
« Last Edit: January 08, 2016, 04:51:05 am by makinero »

Offline Willy2

  • Hero Member
  • *****
  • Join Date: Oct 2011
  • Posts: 1165
  • Karma: 18
    • View Profile
Re: Clean Memory - issue
« Reply #5 on: January 08, 2016, 11:48:47 am »
- Then I am interested which programs you use to flush the Metafile (cache). Flushmem ? Can you post more info on those programs (websites) ?
- Did some more research (GOOGLE) and came across something interesting (Yes, it also involves "Cleanmem"). I found this:
http://serverfault.com/questions/325277/windows-server-2008-r2-metafile-ram-usage

The user also had problems (supposedly). The user reduced the Metafile (cache) size by restarting his system. But a large part of the metafile simply moved from the "In Use" part to the "Standby" portion of the memory. See the pictures made with RAMMAP in the link above.

Then I personally did some testing on my own system as well (RAMMAP). As mentioned before Cleanmem offers the user to collapse the system file cache as well. And it turns out that this collapsing of the system file cache reduces the size of the Metafile in the "In Use" part of the memory as well. Although a sizeable part of that Metafile is pushed to "Standby".

Still have to try Flushmem, though. Although it seems to use the SetWorkingSet API and that's something I don't like too much.
« Last Edit: January 08, 2016, 11:51:11 am by Willy2 »

makinero

  • Guest
Re: Clean Memory - issue
« Reply #6 on: January 08, 2016, 01:12:26 pm »
I do not use Flushmem.

I use three small applications Sysinternals to reducing the consumption of RAM.
Actually, I do not use any applications to reduce memory 16 GB of RAM - so much physical memory is sufficient for using a demanding applications (which use a few GB of RAM).
However, remember to turn on virtual memory (pagefile.sys) even if you have a lot of physical memory.

« Last Edit: January 08, 2016, 03:52:16 pm by makinero »

Offline Willy2

  • Hero Member
  • *****
  • Join Date: Oct 2011
  • Posts: 1165
  • Karma: 18
    • View Profile
Re: Clean Memory - issue
« Reply #7 on: January 08, 2016, 04:14:44 pm »
- Flushmem:  I thought as much. I am VERY hesitant to use Flushmem as well.
- But I am still curious what other program(s) (from Sysinternals) you do use. I am VERY curious.

makinero

  • Guest
Re: Clean Memory - issue
« Reply #8 on: January 09, 2016, 01:18:03 am »
Flushmem is a dangerous application allocates a full RAM (100% RAM) or get an error message Out-Of-Memory or other memory errors.
People are naturally curious but I never he likes to share her knowledge.

Offline Julian

  • "Professional Googler"
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Jun 2015
  • Posts: 1325
  • Location: USA, New Mexico
  • Karma: 38
    • View Profile
Re: Clean Memory - issue
« Reply #9 on: January 10, 2016, 04:47:25 pm »
Quote
People are naturally curious but I never he likes to share her knowledge.
famous quote of shanes lol
Quote
Knowledge should be shared not hidden.
Julian

Offline Boggin

  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Jul 2014
  • Posts: 10182
  • Location: UK
  • Karma: 122
    • View Profile
Re: Clean Memory - issue
« Reply #10 on: January 11, 2016, 03:46:49 am »
+1 for that.

I think if Shane hadn't shared his knowledge, there'd be quite a few (including MS techs :D) who'd be struggling to find a solution.

Offline Samson

  • Hero Member
  • *****
  • Join Date: Nov 2011
  • Posts: 915
  • Location: London
  • Karma: 38
    • View Profile
Re: Clean Memory - issue
« Reply #11 on: January 11, 2016, 04:17:15 am »

"Very truly I tell you, no one can see the kingdom of God unless they are born again."

"Do not neglect to do good and to share what you have, for such sacrifices are pleasing to God."  - Hebrews 13:16  :smiley:


makinero

  • Guest
Re: Clean Memory - issue
« Reply #12 on: January 11, 2016, 04:44:32 am »
Copy SetSystemFileCacheSize.exe
http://www.softpedia.com/get/System/System-Miscellaneous/SetSystemFileCacheSize.shtml
and EmptyStandbyList.exe
http://www.mediafire.com/download/epo2qh9s1ic4q6f/EmptyStandbyList.zip
to C:\Windows\System32\
Create simple batch file to execute 
Code: [Select]
SetSystemFileCacheSize.exe flush and
Code: [Select]
EmptyStandbyList.exe (Run as Administrator)
Create a Task to run the batch file as often as needed.
Most often used for Windows Server 2012 (or in some rare cases to Windows 7 if all the time you save something for hdd (make a backup copy etc.)
« Last Edit: January 11, 2016, 04:49:21 am by makinero »

Offline Boggin

  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Jul 2014
  • Posts: 10182
  • Location: UK
  • Karma: 122
    • View Profile
Re: Clean Memory - issue
« Reply #13 on: January 11, 2016, 04:49:19 am »

"Do not neglect to do good and to share what you have, for such sacrifices are pleasing to God."  - Hebrews 13:16  :smiley:

I wonder if the guy who wrote that was a conman or a Tax Collector :)


Offline Samson

  • Hero Member
  • *****
  • Join Date: Nov 2011
  • Posts: 915
  • Location: London
  • Karma: 38
    • View Profile
Re: Clean Memory - issue
« Reply #14 on: January 11, 2016, 04:59:24 am »
I wonder if the guy who wrote that was a conman or a Tax Collector :)

Probably the former, I can't imagine a tax collector being that creative  :wink:

Offline Willy2

  • Hero Member
  • *****
  • Join Date: Oct 2011
  • Posts: 1165
  • Karma: 18
    • View Profile
Re: Clean Memory - issue
« Reply #15 on: January 12, 2016, 09:17:39 am »
- I searched the Sysinternals' website but found only one memory related program. A program that pushes all the content of the memory to the pagefile. Precisely the kind of "snake oil" that causes a hiccup in the execution of Windows.
- The only program I regularly use is "EmptyStandby.exe" (Task Scheduler) and I have Cleanmem installed. And I let Windows manage the size of the pagefile.
- Nearly all programs that use the "EmptyWorkingSet" API, run in the background, eating up (some) computing power/CPU. But Cleanmem is started by Task Scheduler and closes itself after having done all its jobs. So, no un-necessary loss of resources.

makinero

  • Guest
Re: Clean Memory - issue
« Reply #16 on: January 17, 2016, 01:23:39 am »
I remember that I once
  big problems with large memory usage(I had installed 8 - 10 GB of physical memory), so I decided to buy more physical memory 16 GB (I wanted to use several applications at the same time)
You can reduce caching/buffer on Windows Server 2012 or Windows 7 (if necessary)

To solve the problem of high memory usage and I used this script helps and and install
Microsoft Windows Dynamic Cache Service

http://blogs.msdn.com/b/ntdebugging/archive/2009/02/06/microsoft-windows-dynamic-cache-service.aspx

and

http://blogs.msdn.com/b/ntdebugging/archive/2007/11/27/too-much-cache.aspx

Code: [Select]


# Filename: setfc.ps1
$version = 1.1

#########################
# Settings
#########################

# The percentage of physical ram that will be used for SetSystemFileCache Maximum
$MaxPercent = 12.5

#########################
# Init multipliers
#########################
$OSBits = ([System.IntPtr]::Size) * 8
switch ( $OSBits)
{
    32 { $KiB = [int]1024 }
    64 { $KiB = [long]1024 }
    default {
        # not 32 or 64 bit OS. what are you doing??
        $KiB = 1024 # and hope it works anyway
        write-output "You have a weird OS which is $OSBits bit. Having a go anyway."
    }
}
# These values "inherit" the data type from $KiB
$MiB = 1024 * $KiB
$GiB = 1024 * $MiB
$TiB = 1024 * $GiB
$PiB = 1024 * $TiB
$EiB = 1024 * $PiB


#########################
# Calculated Settings
#########################

# Note that because we are using signed integers instead of unsigned
# these values are "limited" to 2 GiB or 8 EiB for 32/64 bit OSes respectively

$PhysicalRam = 0
$PhysicalRam = [long](invoke-expression (((get-wmiobject -class "win32_physicalmemory").Capacity) -join '+'))
if ( -not $? ) {
    write-output "Trying another method of detecting amount of installed RAM."
 }
if ($PhysicalRam -eq 0) {
    $PhysicalRam = [long]((Get-WmiObject -Class Win32_ComputerSystem).TotalPhysicalMemory) # gives value a bit less than actual
}
if ($PhysicalRam -eq 0) {
    write-error "Cannot Detect Physical Ram Installed. Assuming 4 GiB."
    $PhysicalRam = 4 * $GiB
}
$NewMax = [long]($PhysicalRam * 0.01 * $MaxPercent)
# The default value
# $NewMax = 1 * $TiB


#########################
# constants
#########################

# Flags bits
$FILE_CACHE_MAX_HARD_ENABLE     = 1
$FILE_CACHE_MAX_HARD_DISABLE    = 2
$FILE_CACHE_MIN_HARD_ENABLE     = 4
$FILE_CACHE_MIN_HARD_DISABLE    = 8


################################
# C# code
# for interface to kernel32.dll
################################
$source = @"
using System;
using System.Runtime.InteropServices;

namespace MyTools
{
    public static class cache
    {
        [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern bool GetSystemFileCacheSize(
            ref IntPtr lpMinimumFileCacheSize,
            ref IntPtr lpMaximumFileCacheSize,
            ref IntPtr lpFlags
            );

        [DllImport("kernel32", SetLastError = true, CharSet = CharSet.Unicode)]
        public static extern bool SetSystemFileCacheSize(
          IntPtr MinimumFileCacheSize,
          IntPtr MaximumFileCacheSize,
          Int32 Flags
        );

        [DllImport("kernel32", CharSet = CharSet.Unicode)]
        public static extern int GetLastError();

        public static bool Get( ref IntPtr a, ref IntPtr c, ref IntPtr d )
        {
            IntPtr lpMinimumFileCacheSize = IntPtr.Zero;
            IntPtr lpMaximumFileCacheSize = IntPtr.Zero;
            IntPtr lpFlags = IntPtr.Zero;

            bool b = GetSystemFileCacheSize(ref lpMinimumFileCacheSize, ref lpMaximumFileCacheSize, ref lpFlags);

            a = lpMinimumFileCacheSize;
            c = lpMaximumFileCacheSize;
            d = lpFlags;
            return b;
        }


        public static bool Set( IntPtr MinimumFileCacheSize, IntPtr MaximumFileCacheSize, Int32 Flags )
        {
            bool b = SetSystemFileCacheSize( MinimumFileCacheSize, MaximumFileCacheSize, Flags );
            if ( !b ) {
                Console.Write("SetSystemFileCacheSize returned Error with GetLastError = ");
                Console.WriteLine( GetLastError() );
            }
            return b;
        }
    }

    public class AdjPriv
    {
        [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
        internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall, ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);

        [DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
        internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);

        [DllImport("advapi32.dll", SetLastError = true)]
        internal static extern bool LookupPrivilegeValue(string host, string name, ref long pluid);

        [StructLayout(LayoutKind.Sequential, Pack = 1)]
        internal struct TokPriv1Luid
        {
            public int Count;
            public long Luid;
            public int Attr;
        }
        internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
        internal const int SE_PRIVILEGE_DISABLED = 0x00000000;
        internal const int TOKEN_QUERY = 0x00000008;
        internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;

        public static bool EnablePrivilege(long processHandle, string privilege, bool disable)
        {
            bool retVal;
            TokPriv1Luid tp;
            IntPtr hproc = new IntPtr(processHandle);
            IntPtr htok = IntPtr.Zero;
            retVal = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
            tp.Count = 1;
            tp.Luid = 0;
            if(disable)
            {
                tp.Attr = SE_PRIVILEGE_DISABLED;
            } else {
                tp.Attr = SE_PRIVILEGE_ENABLED;
            }
            retVal = LookupPrivilegeValue(null, privilege, ref tp.Luid);
            retVal = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
            return retVal;
        }
    }
}
"@
# Add the c# code to the powershell type definitions
Add-Type -TypeDefinition $source -Language CSharp

#########################
# Powershell Functions
#########################
function output-flags ($flags)
{
    Write-output ("FILE_CACHE_MAX_HARD_ENABLE  : " + (($flags -band $FILE_CACHE_MAX_HARD_ENABLE) -gt 0) )
    Write-output ("FILE_CACHE_MAX_HARD_DISABLE : " + (($flags -band $FILE_CACHE_MAX_HARD_DISABLE) -gt 0) )
    Write-output ("FILE_CACHE_MIN_HARD_ENABLE  : " + (($flags -band $FILE_CACHE_MIN_HARD_ENABLE) -gt 0) )
    Write-output ("FILE_CACHE_MIN_HARD_DISABLE : " + (($flags -band $FILE_CACHE_MIN_HARD_DISABLE) -gt 0) )
    write-output ""
}

#########################
# Main program
#########################

write-output ""

#########################
# Get and set privilege info
$ProcessId = $pid
$processHandle = (Get-Process -id $ProcessId).Handle
$Privilege = "SeIncreaseQuotaPrivilege"
$Disable = $false
Write-output ("Enabling SE_INCREASE_QUOTA_NAME status: " + [MyTools.AdjPriv]::EnablePrivilege($processHandle, $Privilege, $Disable) )

write-output ("Program has elevated privledges: " + ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") )
write-output ""
whoami /PRIV | findstr /I "SeIncreaseQuotaPrivilege" | findstr /I "Enabled"
if ( -not $? )  {
    write-error "user Security Token SE_INCREASE_QUOTA_NAME: Disabled`r`n"
}
write-output "`r`n"


#########################
# Get Current Settings
# Init variables
$SFCMin = 0
$SFCMax = 0
$SFCFlags = 0
#Get Current values from kernel
$status = [MyTools.cache]::Get( [ref]$SFCMin, [ref]$SFCMax, [ref]$SFCFlags )
#typecast values so we can do some math with them
$SFCMin = [long]$SFCMin
$SFCMax = [long]$SFCMax
$SFCFlags = [long]$SFCFlags
write-output "Return values from GetSystemFileCacheSize are: "
write-output "Function Result : $status"
write-output "            Min : $SFCMin"
write-output ("            Max : $SFCMax ( " + $SFCMax / 1024 / 1024 / 1024 + " GiB )")
write-output "          Flags : $SFCFlags"
output-flags $SFCFlags


#########################
# Output our intentions
write-output ("Physical Memory Detected : $PhysicalRam ( " + $PhysicalRam / $GiB + " GiB )")
write-output ("Setting Max to " + $MaxPercent + "% : $NewMax ( " + $NewMax / $MiB + " MiB )`r`n")

#########################
# Set new settings
$SFCFlags = $SFCFlags -bor $FILE_CACHE_MAX_HARD_ENABLE # set max enabled
$SFCFlags = $SFCFlags -band (-bnot $FILE_CACHE_MAX_HARD_DISABLE) # unset max dissabled if set
# or if you want to override this calculated value
# $SFCFlags = 0
$status = [MyTools.cache]::Set( $SFCMin, $NewMax, $SFCFlags ) # calls the c# routine that makes the kernel API call
write-output "Set function returned: $status`r`n"
# if it was successfull the new SystemFileCache maximum will be NewMax
if ( $status ) {
    $SFCMax = $NewMax
}


#########################
# After setting the new values, get them back from the system to confirm
# Re-Init variables
$SFCMin = 0
$SFCMax = 0
$SFCFlags = 0
#Get Current values from kernel
$status = [MyTools.cache]::Get( [ref]$SFCMin, [ref]$SFCMax, [ref]$SFCFlags )
#typecast values so we can do some math with them
$SFCMin = [long]$SFCMin
$SFCMax = [long]$SFCMax
$SFCFlags = [long]$SFCFlags
write-output "Return values from GetSystemFileCacheSize are: "
write-output "Function Result : $status"
write-output "            Min : $SFCMin"
write-output ("            Max : $SFCMax ( " + $SFCMax / 1024 / 1024 / 1024 + " GiB )")
write-output "          Flags : $SFCFlags"
output-flags $SFCFlags

« Last Edit: January 17, 2016, 01:27:44 am by makinero »

makinero

  • Guest
Re: Clean Memory - issue
« Reply #17 on: January 21, 2016, 02:06:10 pm »
Clean Memory does not always work :) plugin-container.exe (Flash) - large consumption of RAM :)

« Last Edit: January 21, 2016, 02:32:15 pm by makinero »

Offline Willy2

  • Hero Member
  • *****
  • Join Date: Oct 2011
  • Posts: 1165
  • Karma: 18
    • View Profile
Re: Clean Memory - issue
« Reply #18 on: January 21, 2016, 02:08:58 pm »
I found this (interesting) article on the Microsoft website in which is detailed how using the Windows API SetSystemFileCacheSize one can flush the system cache. And that system cache shows up in Resource Monitor as the "Standby" memory.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa965240(v=vs.85).aspx

@Shane: To be added to the "Advanced Monitor" next version of CLEANMEM ? I DO think it could or even is a good addition for that program.

makinero

  • Guest
Re: Clean Memory - issue
« Reply #19 on: January 21, 2016, 02:38:45 pm »

makinero

  • Guest
Re: Clean Memory - issue
« Reply #20 on: January 21, 2016, 02:42:24 pm »
Large Memory Usage in Flash Player :undecided:

Quote
http://s27.postimg.org/re79drj9f/Screen_Shot_01_21_16_at_10_55_PM.jpg

https://support.mozilla.org/pl/questions/925251

Not found (New versions Firefox)
dom.ipc.plugins.enabled

« Last Edit: January 21, 2016, 02:44:26 pm by makinero »

Offline Willy2

  • Hero Member
  • *****
  • Join Date: Oct 2011
  • Posts: 1165
  • Karma: 18
    • View Profile
Re: Clean Memory - issue
« Reply #21 on: January 21, 2016, 02:48:15 pm »
- "Clean memory doesn't Always work" Are refering to "Cleanmem" ? Yes, sometimes programs reclaim A LOT OF or even ALL memory that Cleanmem has taken away. And it sometimes even the program INCREASES memory usage.

One example:
http://forums.pcwintech.com/index.php/topic,5403.0.html


makinero

  • Guest
Re: Clean Memory - issue
« Reply #22 on: January 21, 2016, 05:21:07 pm »
Willy2 - I mean, just for a moment that reduces memory and memory usage grows again . . .  :wink:


1. My system automatically creates a 16GB PAGEFILE.SYS
  and does not show annoying details that lack of memory in the system (although I noticed a "short moments" freezes (because it uses PAGEFILE - perhaps?)

2. ASUS Suite 3
The second reason that I set to "Power Saving"
I do not want to use the "Performance" - because I want to reduce the temperature and reducing processor power :)
« Last Edit: January 21, 2016, 05:27:33 pm by makinero »