Memory consists of physical and virtual memory. You need to consider how much memory is allocated to your application. When you evaluate memory-related bottlenecks, consider unnecessary allocations, inefficient clean up, and inappropriate caching and state management mechanisms. To resolve memory-related bottlenecks, optimize your code to eliminate these issues and then tune the amount of memory allocated to your application. If you determine during tuning that memory contention and excessive paging are occurring, you may need to add more physical memory to the server.
Low memory leads to increased paging where pages of your application’s virtual
address space are written to and from disk. If paging becomes excessive, page
thrashing occurs and intensive disk I/O decreases overall system performance.
Configuration Overview
Memory tuning consists of the following:
- Determine whether your application has a memory bottleneck. If
it has, then add more memory.
- Tune the amount of memory allocated if you can control the
allocation. For example, you can tune this for ASP.NET and
SQL Server.
- Tune the page file size.
Metrics
The performance counters help you identify memory bottlenecks. You should log these counter values to log files over a 24 hour period before you form any conclusions.
Memory
- Available MBytes
- Page Reads/sec
- Pages/sec
- Cache Bytes
- Cache Faults/sec
Server
- Pool Nonpaged Failures
- Pool Nonpaged Peak
Cache
- MDL Read Hits %
Bottlenecks
A low value of Available MBytes indicates that your system is low on physical
memory, caused either by system memory limitations or an application that is not
releasing memory. Monitor each process object’s working set counter. If Available
MBytes remains high even when the process is not active, it might indicate that the
object is not releasing memory. Use the CLR Profiler tool at this point to identify the source of any memory allocation problems. For more information, see “How To: Use
CLR Profiler” in the “How To” section of this guide.
A high value of Pages/sec indicates that your application does not have sufficient
memory. The average of Pages Input/sec divided by average of Page Reads/sec gives
the number of pages per disk read. This value should not generally exceed five pages
per second. A value greater than five pages per second indicates that the system is
spending too much time paging and requires more memory (assuming that the
application has been optimized).
Tuning Options
If you determine that your application has memory issues, your options include
adding more memory, stopping services that you do not require, and removing
unnecessary protocols and drivers. Tuning considerations include:
- Deciding when to add memory
- Page file optimization
Deciding When to Add Memory
To determine the impact of excessive paging on disk activity, multiply the values of
the Physical Disk\ Avg. Disk sec/Transfer and Memory\ Pages/sec counters. If the
product of these counters exceeds 0.1, paging is taking more than 10 percent of disk
access time. If this occurs over a long period, you probably need more memory. After
upgrading your system’s memory, measure and monitor again.
To save memory:
- Turn off services you do not use. Stopping services
that you do not use regularly saves memory and improves
system performance.
- Remove unnecessary protocols and drivers. Even idle
protocols use space in the paged and nonpaged memory
pools. Drivers also consume memory, so you should remove
unnecessary ones.
Page File Optimization
You should optimize the page file to improve the virtual memory performance of
your server. The combination of physical memory and the page file is called the
virtual memory of the system. When the system does not have enough physical
memory to execute a process, it uses the page file on disk as an extended memory
source. This approach slows performance.
To ensure an optimized page file:
- Increase the page file size on the system to 1.5 times
the size of physical memory available, but only to
a maximum of 4,095 MB. The page file needs to be at least
the size of the physical memory to allow the memory to be
written to the page file in the event of a system crash.
- Make sure that the page file is not fragmented on a given partition.
- Separate the data files and the page file to different
disks only if the disk is a bottleneck because of a lot
of I/O operation. These files should preferably be on the
same physical drive and the same logical partition. This
keeps the data files and the page file physically close to
each other and avoids the time spent seeking between two
different logical drives.
To configure the page file size
1. Open Control Panel.
2. Double-click the System icon.
3. Select the Advanced tab.
4. Click Performance Options.
5. Click Change. The Virtual Memory dialog box appears
6. Enter new values for Initial size and Maximum size. Click Set, and then click OK.
Saturday, May 08, 2010
Memory
Subscribe to:
Post Comments (Atom)
Shared Cache - .Net Caching made easy
All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.
No comments:
Post a Comment