Unallocated space is the free room inside a SQL Server database’s data or log files that has been reserved by the file but is not currently assigned to any object, page, or log block; in a data file it is the area beyond the last allocated extent, and in a log file it is the portion of the file not yet holding active or reusable log records. It is distinct from free space inside already allocated pages and from free space inside allocated extents, and mixing those categories is the usual source of confusion about why a database file “has space” but still grows.
The file-level picture
A SQL Server database is backed by at least two operating-system files: one or more data files (.mdf primary, .ndf secondary) and one or more log files (.ldf). Each file has a size on disk. Inside a data file, SQL Server organizes storage in 8 KB pages, groups eight contiguous pages into a 64 KB extent, and tracks which extents belong to which allocation unit (IN_ROW_DATA, ROW_OVERFLOW_DATA, LOB_DATA) for which object. Anything inside the file that is not part of an allocated extent is unallocated.
Unallocated space is therefore a property of a specific file, not of the database as a whole. A database with several data files can be tight in one file and spacious in another. Queries such as sys.dm_db_file_space_usage, sys.dm_db_partition_stats, and FILEPROPERTY(name, 'SpaceUsed') report per-file or per-allocation-unit figures, which is why totals across files can look inconsistent if you treat them as one pool.
The practical meaning: unallocated space is the file’s headroom for new allocations. When SQL Server needs a new extent for a table, index, or internal structure and no reusable free extent fits, it takes from unallocated space. If unallocated space runs out, the file grows according to its growth settings (or the operation fails if growth is disabled or the disk is full).
What “unallocated” is not
Several free-space concepts in SQL Server are easy to conflate:
Unallocated space — untouched area inside the file, not owned by any extent. Free space in allocated extents — extents assigned to an allocation unit that still have unused pages. These are reusable without growing the file. Free space on pages — the unused bytes on a page already holding rows. This matters for row inserts and updates but never causes or prevents file growth directly. Reserved space — the total of allocated extents attributed to an allocation unit, reported by sys.dm_db_partition_stats as reserved_page_count. Index fragmentation — logically out-of-order pages, unrelated to unallocated space except that rebuilds temporarily need working room. Ghost records and deferred deallocation — deleted rows whose space is pending cleanup; this appears as allocated-but-reclaimable space, not unallocated space.
A common report shows a 100 GB data file, 40 GB used, 60 GB “free.” That 60 GB is largely unallocated, but it can also include free pages inside allocated extents depending on which DMV produced the number. FILEPROPERTY('SpaceUsed') and sys.database_files.size give the file-level view: size is in 8 KB pages, SpaceUsed is allocated pages, and the difference is the unallocated portion. sys.dm_db_file_space_usage splits the file into unallocated extents, mixed extents, and uniform extents, which is more precise than a single “free” figure.
Log files behave differently
In a transaction log, “unallocated” means the portion of the log file beyond the virtual log files (VLFs) currently in use or available for reuse. The log is written sequentially as a ring of VLFs. Space becomes reusable when a log backup (in full or bulk-logged recovery) or a checkpoint (in simple recovery) advances the log truncation point. That reusable space is inside the file; it is not returned to the operating system unless the file is shrunk.
So a 20 GB log file with 2 GB of active log can show 18 GB as “free” in DBCC SQLPERF(LOGSPACE) or sys.dm_db_log_space_usage, yet none of that is unallocated in the data-file sense. Shrinking the log file converts reusable logical space into reduced file size; that is a file-size action, not an allocation action. Confusing log free space with data-file unallocated space leads to unnecessary shrinks, which fragment VLFs and cause performance problems.
Why unallocated space is normal and often desirable
Every database that has been in use has unallocated space unless it was just created and immediately filled. SQL Server allocates extents in 64 KB chunks; a table that grows from 1 MB to 1.5 MB needs another extent, and the file must contain room for it. Preallocated unallocated space avoids autogrowth pauses during inserts, index rebuilds, and sort operations. A data file with 20% unallocated space is generally in better operational shape than one at 99% utilization, because the next large operation will not queue on a file-growth event.
Autogrowth is not free: each growth event takes a file-growth lock, may zero-initialize new pages (depending on instant file initialization and the operation), and on busy systems can cause latency spikes. Unallocated space is the buffer that keeps those events rare. That is why many DBAs pre-size files well beyond current usage rather than relying on small percentage-based growth increments.
A reproducible example
Create a database with a 100 MB data file and a 50 MB log file, then create one table and insert rows until the table reaches roughly 10 MB.
After the inserts, sys.database_files shows size around 12,800 pages (100 MB at 8 KB per page) and FILEPROPERTY('SpaceUsed') at roughly 1,300 pages for the ~10 MB table plus overhead. The difference—about 11,500 pages, or roughly 90 MB—is largely unallocated space in the data file. The log file will show a much smaller used portion against its 50 MB size; that log free space is reusable, not unallocated in the data sense. Run DBCC SQLPERF(LOGSPACE) and sys.dm_db_file_space_usage to see the split.
Drop the table and the pages become unallocated again in principle, but notice the timing: deallocation is not instantaneous page-by-page; ghost cleanup and deferred drop complete asynchronously. For a while the space is allocated-but-pending-reclaim, then becomes unallocated. Tools that sample once may catch the intermediate state.
Ambiguity in the question
The phrase “unallocated space in a SQL Server database” can mean at least three things, and the answer differs:
1: Unallocated extents inside a data file — the default reading, covered above. 2: Unallocated space in the storage volume hosting the files — free disk space outside the database files, which SQL Server does not track and which you must check with the operating system or sys.dm_os_volume_stats. 3: “Unallocated space” in a backup or restore context — space in the file that the backup stream marks as unused, restored as unallocated; this matters for restore sizing.
Without the source passage, edition, and SQL Server version, the safest reading is the first. If the question came from a monitoring dashboard, a shrink discussion, or an autogrowth alert, the intended meaning is especially worth confirming, because “free” figures on different screens measure different things.
Version and edition also matter. SQL Server 2016 and later changed some allocation accounting and added sys.dm_db_file_space_usage columns; Azure SQL Database abstracts file management and may show space differently; SQL Server on Linux behaves the same at the storage-engine level but instant file initialization support varies by filesystem and configuration. The core model—page, extent, allocation unit, file—has been stable for decades, but reporting surfaces have changed.
Diagnosing and acting on it
Use these views together rather than one at a time:
If unallocated space is small and the file is near its maximum size, growth settings or disk capacity need attention. If unallocated space is large but the file is not expected to grow, that is usually fine—do not shrink the data file just because unallocated space exists. Shrinking a data file below its working set forces regrowth later, fragments indexes, and can move pages away from sequential access patterns, increasing fragmentation and I/O for range scans.
Shrinking a data file is warranted when you have decisively removed data (dropped a large table, moved an archive to another filegroup), verified with a rebuild of affected indexes, and confirmed the file cannot usefully remain large. Even then, prefer DBCC SHRINKFILE on specific files with a known target rather than DBCC SHRINKDATABASE, which shrinks every file and tries to balance free space among them.
For log files, unallocated space and reusable log space are different. DBCC SHRINKFILE on the log truncates reusable VLFs and reduces the file; doing this routinely defeats the point of pre-sizing and is associated with log fragmentation (many small VLFs) and slower log operations. Manage the log with regular backups and appropriately sized preallocation, not shrink cycles.
Common misconceptions
“Unallocated space means the database is corrupt or leaking.” It is normal reserved headroom that the engine manages; nothing is leaking. “Shrinking the database will make queries faster.” Usually the opposite for data files; I/O per page often rises after a shrink because the working set no longer fits the original layout. “The free space on my data file shown by one DMV is the whole story.” FILEPROPERTY and sys.dm_db_file_space_usage measure different layers; neither includes free bytes inside allocated pages. “Free space inside pages is unallocated.” It is allocated and owned; it just has no rows in it, and it is reused on inserts and updates. “A freshly created database has no unallocated space.” Model and template copies, internal structures, and preallocated file sizes mean almost any usable database already has some.
Where the concept stops applying
Unallocated space is a storage-engine concept. It does not apply to memory-mapped in-memory OLTP tables in the same way, where memory-optimized data lives in checkpoint files and in-memory structures rather than traditional data-file extents; the file still exists, but “unallocated extents” is not the right mental model. It also does not directly describe space inside FILESTREAM or FileTable data containers, which are managed as filesystem directories and have their own allocation patterns. And it says nothing about columnstore compression, which stores data in rowgroups and compressed segments; a columnstore index with small rowgroups can contain allocated but heavily inefficient space even when unallocated space in the file is ample.
For everyday tables and indexes, though, the rule holds: unallocated space is the file’s free reserve above the allocated extents, it is normal, and it is best managed by pre-sizing files and setting sensible fixed-size (MB) growth increments rather than by frequent shrinks.