释放SQL Server占用的内存
转载至:http://www.imkevinyang.com/2009/09/%E9%87%8A%E6%94%BEsql-server%E5%8D%A0%E7%94%A8%E7%9A%84%E5%86%85%E5%AD%98.html 释放 SQL Server 占用 的 内存 技术随笔 SQL,SQL Server, 内存 , 内存 释放 由于Sql Server对于系统 内存 的管理策略是有多少
转载至:http://www.imkevinyang.com/2009/09/%E9%87%8A%E6%94%BEsql-server%E5%8D%A0%E7%94%A8%E7%9A%84%E5%86%85%E5%AD%98.html
释放SQL Server占用的内存
技术随笔
由于Sql Server对于系统内存的管理策略是有多少占多少,除非系统内存不够用了(大约到剩余内存为4M左右),Sql Server才会释放一点点内存。所以很多时候,我们会发现运行Sql Server的系统内存往往居高不下。
这些内存一般都是Sql Server运行时候用作缓存的,例如你运行一个select语句,那么Sql Server会将相关的数据页(Sql Server操作的数据都是以页为单位的)加载到内存中来,下一次如果再次请求此页的数据的时候,就无需读取磁盘了,大大提高了速度。这类的缓存叫做数据缓存。还有一些其他类型的缓存,如执行存储过程时,Sql Server需要先编译再运行,编译后的结果也会缓存起来,下一次就无需再次编译了。如果这些缓存已经不需要了,那么我们可以调用以下几个DBCC管理命令来清理这些缓存:
<span class="kwrd">DBCC</span> FREEPROCCACHE <span class="kwrd">DBCC</span> FREESESSIONCACHE <span class="kwrd">DBCC</span> FREESYSTEMCACHE(<span class="str">'All'</span>) <span class="kwrd">DBCC</span> DROPCLEANBUFFERS
这几个命令分别用来清除存储过程相关的缓存、会话缓存、系统缓存以及所有所有缓存。详细的使用参考MSDN。
但是需要注意的是,这几个命令虽然会清除掉现有缓存,为新的缓存腾地方,但是Sql server并不会因此释放掉已经占用的内存。无奈的是,Sql Server并没有提供任何命令允许我们释放不用到的内存。因此我们只能通过动态调整Sql Server可用的物理内存设置来强迫它释放内存。
<span class="kwrd">USE</span> master <span class="rem">-- 打开高级设置配置</span> <span class="kwrd">EXEC</span> sp_configure <span class="str">'show advanced options'</span>, 1 <span class="kwrd">RECONFIGURE</span> <span class="kwrd">WITH</span> OVERRIDE <span class="rem">-- 先设置物理<strong>内存</strong>上限到1G</span> <span class="kwrd">EXEC</span> sp_configure <span class="str">'max server memory (MB)'</span>, 1024 <span class="kwrd">RECONFIGURE</span> <span class="kwrd">WITH</span> OVERRIDE <span class="rem">-- 还原原先的上限</span> <span class="kwrd">EXEC</span> sp_configure <span class="str">'max server memory (MB)'</span>, 5120 <span class="kwrd">RECONFIGURE</span> <span class="kwrd">WITH</span> OVERRIDE <span class="rem">-- 恢复默认配置</span> <span class="kwrd">EXEC</span> sp_configure <span class="str">'show advanced options'</span>, 0 <span class="kwrd">RECONFIGURE</span> <span class="kwrd">WITH</span> OVERRIDE
我们也可以通过Sql Server Management企业管理器进行动态控制。连接到企业管理器之后打开Sql Server实例的属性面板,找到内存设置,改变其中的最大服务器内存使用即可。
——Kevin Yang

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



For mechanical hard drives or SATA solid-state drives, you will feel the increase in software running speed. If it is an NVME hard drive, you may not feel it. 1. Import the registry into the desktop and create a new text document, copy and paste the following content, save it as 1.reg, then right-click to merge and restart the computer. WindowsRegistryEditorVersion5.00[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\MemoryManagement]"DisablePagingExecutive"=d

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

According to the report, Samsung Electronics executive Dae Woo Kim said that at the 2024 Korean Microelectronics and Packaging Society Annual Meeting, Samsung Electronics will complete the verification of the 16-layer hybrid bonding HBM memory technology. It is reported that this technology has passed technical verification. The report also stated that this technical verification will lay the foundation for the development of the memory market in the next few years. DaeWooKim said that Samsung Electronics has successfully manufactured a 16-layer stacked HBM3 memory based on hybrid bonding technology. The memory sample works normally. In the future, the 16-layer stacked hybrid bonding technology will be used for mass production of HBM4 memory. ▲Image source TheElec, same as below. Compared with the existing bonding process, hybrid bonding does not need to add bumps between DRAM memory layers, but directly connects the upper and lower layers copper to copper.

According to news from this website on September 3, Korean media etnews reported yesterday (local time) that Samsung Electronics and SK Hynix’s “HBM-like” stacked structure mobile memory products will be commercialized after 2026. Sources said that the two Korean memory giants regard stacked mobile memory as an important source of future revenue and plan to expand "HBM-like memory" to smartphones, tablets and laptops to provide power for end-side AI. According to previous reports on this site, Samsung Electronics’ product is called LPWide I/O memory, and SK Hynix calls this technology VFO. The two companies have used roughly the same technical route, which is to combine fan-out packaging and vertical channels. Samsung Electronics’ LPWide I/O memory has a bit width of 512

According to news from this website on May 6, Lexar launched the Ares Wings of War series DDR57600CL36 overclocking memory. The 16GBx2 set will be available for pre-sale at 0:00 on May 7 with a deposit of 50 yuan, and the price is 1,299 yuan. Lexar Wings of War memory uses Hynix A-die memory chips, supports Intel XMP3.0, and provides the following two overclocking presets: 7600MT/s: CL36-46-46-961.4V8000MT/s: CL38-48-49 -1001.45V In terms of heat dissipation, this memory set is equipped with a 1.8mm thick all-aluminum heat dissipation vest and is equipped with PMIC's exclusive thermal conductive silicone grease pad. The memory uses 8 high-brightness LED beads and supports 13 RGB lighting modes.

According to news from this site on June 7, GEIL launched its latest DDR5 solution at the 2024 Taipei International Computer Show, and provided SO-DIMM, CUDIMM, CSODIMM, CAMM2 and LPCAMM2 versions to choose from. ▲Picture source: Wccftech As shown in the picture, the CAMM2/LPCAMM2 memory exhibited by Jinbang adopts a very compact design, can provide a maximum capacity of 128GB, and a speed of up to 8533MT/s. Some of these products can even be stable on the AMDAM5 platform Overclocked to 9000MT/s without any auxiliary cooling. According to reports, Jinbang’s 2024 Polaris RGBDDR5 series memory can provide up to 8400

According to a TrendForce survey report, the AI wave has a significant impact on the DRAM memory and NAND flash memory markets. In this site’s news on May 7, TrendForce said in its latest research report today that the agency has increased the contract price increases for two types of storage products this quarter. Specifically, TrendForce originally estimated that the DRAM memory contract price in the second quarter of 2024 will increase by 3~8%, and now estimates it at 13~18%; in terms of NAND flash memory, the original estimate will increase by 13~18%, and the new estimate is 15%. ~20%, only eMMC/UFS has a lower increase of 10%. ▲Image source TrendForce TrendForce stated that the agency originally expected to continue to

When the prices of ultra-high-frequency flagship memories such as 7600MT/s and 8000MT/s are generally high, Lexar has taken action. They have launched a new memory series called Ares Wings ARES RGB DDR5, with 7600 C36 and 8000 C38 is available in two specifications. The 16GB*2 sets are priced at 1,299 yuan and 1,499 yuan respectively, which is very cost-effective. This site has obtained the 8000 C38 version of Wings of War, and will bring you its unboxing pictures. The packaging of Lexar Wings ARES RGB DDR5 memory is well designed, using eye-catching black and red color schemes with colorful printing. There is an exclusive &quo in the upper left corner of the packaging.
