Is it true that Windows registry files grow but never shrink?

Status
Not open for further replies.

MrChad

Lifer
Aug 22, 2001
13,507
3
81
I remember hearing this statement back in the 9x days, but I'm wondering if it still holds true for XP.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
I suppose it's possible to shrink it.

Although most of the time it just gets bigger. When you uninstall stuff it'll usually leave traces of the registry settings here and there. After a while it adds up.

At least that's what I figure.
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Well, perhaps I should add that assuming programs are uninstalling cleanly, does the registry file size ever shrink?
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Well sure it would, I guess.

The registry is like a database, right? So in simplier database files (and some not so simple) say you have a 100 records and you add a record, then you have a 101 records. When you delete a record out of the middle then you have 100 records. However the numbers below the deleted record keep their numbers, so the last record is still 101.

Say you have records numbered: 1, 2, 3, 4, 5
You add two, then you have them numbered: 1, 2, 3, 4, 5, 6, 7
then you delete 4 and 6 then you end up with: 1, 2, 3, *, 5, *, 7
Then you add two: 1, 2, 3, *, 5, *, 7, 8, 9
It keeps everything consistant. To get retreive the unused space requires that you renumber everything, or compress the file in some way. Probably not worth the extra effort.

My guess.
 

mikecel79

Platinum Member
Jan 15, 2002
2,858
1
81
Like drag said the registry is just a database. When you add items it grows but when you delete items it doesn't shrink the file, it just marks it as whitespace. So this way when you do add more to it, the actual file does not need to grow.

For example your registry file is 35MB, and you install an application that adds 1MB to it so it's now 36MB. If you then remove that application and the keys are removed cleanly instead of shrinking the file it just marks that 1MB as whitespace that can be used in the future. So you now have a 36MB registry file with only 35MB of it used.

Many databases work this way (PST files, Access, SQL, etc). It makes for better performance because you don't have to spend time expanding the file when it's needed. On my workstation now my registry file is 38MB with a maximum size of 60MB. This was the way it was created in the beginning. It builds in extra whitespace so it does not need to be expanded.
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Ok, I understand. Since the registry is just a database, is there any weight to the claims by registry "tweaker" software manufacturers that claim to improve performance by "defragging" and compacting the registry file?
 

mikecel79

Platinum Member
Jan 15, 2002
2,858
1
81
Originally posted by: MrChad
Ok, I understand. Since the registry is just a database, is there any weight to the claims by registry "tweaker" software manufacturers that claim to improve performance by "defragging" and compacting the registry file?

I wouldn't touch one of those with a ten foot pole....
 

Phoenix86

Lifer
May 21, 2003
14,644
10
81
Originally posted by: MrChad
Ok, I understand. Since the registry is just a database, is there any weight to the claims by registry "tweaker" software manufacturers that claim to improve performance by "defragging" and compacting the registry file?
It would make sense that you could compact the DB after removing entries. Most DBs will not actually reduce in space until the DB is compacted after deleting files.

As far as "defragging" it, BS, a standard defragmenting program should be able to touch the registry, just not the page file.

Is there truth to this? I'm not sure, but you could test it.
 

thegorx

Senior member
Dec 10, 2003
451
0
0
well the only thing I can think that those programs could do is to export the registry to hive files then replace them at boot up.

whoopee, just using system restore could be that

With windows 9x you could export the whole registry to a reg file
while you can still do that in XP you cannot rebuild the registry with a reg file since it's missing information like permissions and such.

the probelm with XP registry is that it does get messed up
and even if you "compact" it the hive files can still be corrupt or permissions get corrupt
I've seen keys put in by viruses that were real buggers to remove
hardware listings like one system with 20 cd-rw drives listed
so basically every boot or so XP would redetect the CD-RW drive because of corruption

 

uOpt

Golden Member
Oct 19, 2004
1,628
0
0
My understanding is that the Registry is append-only, so yes it only grows and never shrinks.

It does overwrite existing values in place, though.

Not that it matters to me...
 

Smilin

Diamond Member
Mar 4, 2002
7,357
0
0
Originally posted by: MrChad
Ok, I understand. Since the registry is just a database, is there any weight to the claims by registry "tweaker" software manufacturers that claim to improve performance by "defragging" and compacting the registry file?

Bullsh1t.

There. :)


The registry is completely loaded into memory at boot. I supposed you could increase the performance of writing things to the registry but you won't increase the performance of anything that's actually using it.
Any access is done against the copy in memory that's always "defragged".

compacting the registry is a pretty safe procedure but there isn't much point unless you have an oversized hive that won't let you boot. "Defragging" simply makes no sense. "fragmented" on the disk doesn't mean "fragmented" in memory. Besides the registry isn't even stored as keys and values on disk, it's stored in a cell format.
 

VirtualLarry

No Lifer
Aug 25, 2001
56,570
10,202
126
The answer to the question in the topic is: true - the registry file on-disk never shrinks.

I have to totally agree with mikecel79 and Smilin on this one too, there's really not that much need to defrag the registry, nor would I (personally) trust any non-MS third-party utility to do so, except for perhaps one written by the SysInternals guys. They do good stuff, I'm honestly surprised that they aren't on the NT dev team at MS by now. :) (Look at Andrew Schulman, he works for MS now, he literally wrote the book on "Undocumented DOS". At least now he can't testify against MS in any "stacker lawsuits" ever again, heehee.)

It is unfortunately possible, at least in W2K, for minor on-disk registry-corruption to increase the size of one of your registry hives significantly, by making a chunk of it appear allocated when it's really not. That happened to me once, I ended up with like a 20MB system hive.. no, that's can't be right, W2K can't boot with one above 16MB.. maybe I mean 12MB. Anyways, something made it grow once by leaps and bounds after
a crash.

I'm slightly curious though - the "registry size limit" that you can allocate under the VM settings in W2K - is that RAM solely allocated to the in-memory copy of the registry, such that any larger setting just wastes RAM, or is that a maximum size setting? I usually bump mine up from the default, because I almost always hit the default limit eventually with my W2K installs after a time. I usually set it to 64MB, is that a bit too high? I think I usually hit about 20-24MB usage.. 12MB
 

MrChad

Lifer
Aug 22, 2001
13,507
3
81
Originally posted by: VirtualLarry
The answer to the question in the topic is: true - the registry file on-disk never shrinks.

I have to totally agree with mikecel79 and Smilin on this one too, there's really not that much need to defrag the registry, nor would I (personally) trust any non-MS third-party utility to do so, except for perhaps one written by the SysInternals guys. They do good stuff, I'm honestly surprised that they aren't on the NT dev team at MS by now. :) (Look at Andrew Schulman, he works for MS now, he literally wrote the book on "Undocumented DOS". At least now he can't testify against MS in any "stacker lawsuits" ever again, heehee.)

It is unfortunately possible, at least in W2K, for minor on-disk registry-corruption to increase the size of one of your registry hives significantly, by making a chunk of it appear allocated when it's really not. That happened to me once, I ended up with like a 20MB system hive.. no, that's can't be right, W2K can't boot with one above 16MB.. maybe I mean 12MB. Anyways, something made it grow once by leaps and bounds after
a crash.

I'm slightly curious though - the "registry size limit" that you can allocate under the VM settings in W2K - is that RAM solely allocated to the in-memory copy of the registry, such that any larger setting just wastes RAM, or is that a maximum size setting? I usually bump mine up from the default, because I almost always hit the default limit eventually with my W2K installs after a time. I usually set it to 64MB, is that a bit too high? I think I usually hit about 20-24MB usage.. 12MB

Heh, Microsoft's support team uses and recommends Sysinternals freeware. :)
 

mikecel79

Platinum Member
Jan 15, 2002
2,858
1
81
I'm slightly curious though - the "registry size limit" that you can allocate under the VM settings in W2K - is that RAM solely allocated to the in-memory copy of the registry, such that any larger setting just wastes RAM, or is that a maximum size setting? I usually bump mine up from the default, because I almost always hit the default limit eventually with my W2K installs after a time. I usually set it to 64MB, is that a bit too high? I think I usually hit about 20-24MB usage.. 12MB

I'm pretty sure this is the size on the disk, not in memory. So using a larger setting probably does not waste memory.
 

Smilin

Diamond Member
Mar 4, 2002
7,357
0
0
That setting is really for your software hive. There is no setting for limiting the system hive. After about 10.5 megs (on most systems - depends on # of drivers & boot services) the system will fail to boot. Software can get pretty big depending on what you have loaded. 64 sounds pretty high. If you get near that you might want to investigate what's using that much.

FYI: I'm at 20mb for my software hive and 7.6mb for my system hive (which compresses down to 5.6mb if I were to bother to strip out whitespace)
 

kylef

Golden Member
Jan 25, 2000
1,430
0
0
Originally posted by: VirtualLarry
I'm slightly curious though - the "registry size limit" that you can allocate under the VM settings in W2K - is that RAM solely allocated to the in-memory copy of the registry, such that any larger setting just wastes RAM, or is that a maximum size setting?
The registry is *mapped* into memory at boot, not loaded. The vast majority sits on disk and is never paged into physical memory by the cache manager.

So that limit has no effect on physical memory usage whatsoever.
 

VirtualLarry

No Lifer
Aug 25, 2001
56,570
10,202
126
Originally posted by: kylef
Originally posted by: VirtualLarry
I'm slightly curious though - the "registry size limit" that you can allocate under the VM settings in W2K - is that RAM solely allocated to the in-memory copy of the registry, such that any larger setting just wastes RAM, or is that a maximum size setting?
The registry is *mapped* into memory at boot, not loaded. The vast majority sits on disk and is never paged into physical memory by the cache manager.

So that limit has no effect on physical memory usage whatsoever.

Well, according to the 3rd and 4th pages here, it is indeed loaded into memory at boot, but it also keeps track of a seperate "dirty page" list, and writes back the modified in-RAM copies to disk at shutdown.

Also, if you think about it, the bootloader has to load the SYSTEM hive into RAM, along with the bootstrap kernel binaries, since the system is still running in real mode at the time, there is no VM paging available. Yet certain key registry settings have to be loaded and available for the kernel and boot-time device-drivers to make use of. I don't know about the USER registry hives, those might be demand-paged, but it would seem simpler to use the same mechanism for both, at least to me.

On the fifth page of that link, he also talks about a way to compact the NT registry, using the ERD to back up and then restore the registry. I'll have to try that, I didn't realize that was an option for "defragmenting". Makes sense.
 

NogginBoink

Diamond Member
Feb 17, 2002
5,322
0
0
It is possible to compact the registry. If you do a RegSaveKey, the configuration manager writes a file to disk without the whitespace.

So if you do a export on HKLM\Software and HKLM\System and save those two files, you'll have compacted versions of those two hives.

Then reboot into another OS, or into recovery console, and replace %windir%\system32\config\system and software with the files you created.

For most folks this is probably not worth it. Use this info at your own risk.
 

Dr.Why

Junior Member
Sep 19, 2013
1
0
0
The idea Nogginboink mentioned seemed like it might work. Using Windows XP, I tried to compact the registry like NogginBoink suggested - using regedit to export the Software and System portions of the registry to a file, then booting up with the registry files created by regedit export. The exported files turned out to be almost exactly the same size as the registry files my computer already had at C:/windows/system32/config. My computer booted up from the exported files just fine, but there was no reduction in the size of either registry file. Apparently regedit export writes the white space (junk) entries in the registry along with the useful parts of the registry. My combined registry files used about 25 MB after a fresh install of XP about 4 years ago. Over the years since then, the registry files have fattened up to 42 MB. Maybe there is a way to shrink the registry without re-installing windows, but I still haven't found it. The size of the registry was not reduced using the Nogginboink method.

Nogginboink, You mentioned RegSaveKey and configuration manager. I don't know what those things are, but I created the exported System and Software files using RegEdit. Is there something I should know about "RegSaveKey" and "configuration manager?"
 

escrow4

Diamond Member
Feb 4, 2013
3,339
122
106
The idea Nogginboink mentioned seemed like it might work. Using Windows XP, I tried to compact the registry like NogginBoink suggested - using regedit to export the Software and System portions of the registry to a file, then booting up with the registry files created by regedit export. The exported files turned out to be almost exactly the same size as the registry files my computer already had at C:/windows/system32/config. My computer booted up from the exported files just fine, but there was no reduction in the size of either registry file. Apparently regedit export writes the white space (junk) entries in the registry along with the useful parts of the registry. My combined registry files used about 25 MB after a fresh install of XP about 4 years ago. Over the years since then, the registry files have fattened up to 42 MB. Maybe there is a way to shrink the registry without re-installing windows, but I still haven't found it. The size of the registry was not reduced using the Nogginboink method.

Nogginboink, You mentioned RegSaveKey and configuration manager. I don't know what those things are, but I created the exported System and Software files using RegEdit. Is there something I should know about "RegSaveKey" and "configuration manager?"

A) Its 2013, not 2004

B) Get off XP

C) Its 42MB. Seriously. Its 2013.

D) Did I mention its 2013?
 
Status
Not open for further replies.