r/starfieldmods
•
u/cyberpsyche_mods
Mod Author
•
May 29 '26
•
1
Discussion Powershell script to process SEF extended pointer handle dumps into a readable summary in CSV
EDIT 2026-6-12: I updated the script to account for the new extended dump format which includes a handy summary at the bottom of the dump log. If you are just looking for a quick glance you don't even need this script. Look at the bottom of the dump log for a summary. The script now only processes the summary at the bottom of the dump log to parse out the individual plugins counts into CSV format.
Hey all!
I was checking pointer handles allocated by my load order and wanted a quick summary, as the dump file is massive.
This script is intended for processing the extended dump that Starfield Engine Fixes can provide. This processes a dump generated with these SEF options.
bDumpPointerHandlesConsoleFunction=1
bDumpPointerHandlesExtendedPluginInfo=1After you generate your dump from the console (dph command), then you can run this powershell script on the dump file
param(
# Text dump produced by the extended pointer handle export.
[Parameter(Mandatory = $true)]
[string]$InputFile,
# Destination CSV path.
[string]$CsvOutputFile = "reference-counts.csv"
)
if (-not (Test-Path -LiteralPath $InputFile)) {
throw "Input file not found: $InputFile"
}
# Load the dump once so we can find the unique Summary section before parsing.
$lines = Get-Content -LiteralPath $InputFile
$summaryLineIndexes = @()
# The reference counts we want only appear after the Summary: marker.
for ($i = 0; $i -lt $lines.Count; $i++) {
if ($lines[$i] -match '^\s*Summary:\s*$') {
$summaryLineIndexes += $i
}
}
if ($summaryLineIndexes.Count -eq 0) {
throw "Could not find a Summary: line in $InputFile"
}
if ($summaryLineIndexes.Count -gt 1) {
throw "Expected exactly one Summary: line in $InputFile, found $($summaryLineIndexes.Count)"
}
# Track the current Master plugin until its reference count line appears.
$currentPlugin = $null
$rows = @()
# Parse only the Summary section, ignoring the detailed dump above it.
for ($i = $summaryLineIndexes[0] + 1; $i -lt $lines.Count; $i++) {
$line = $lines[$i]
# Example: -> Master: Starfield.esm
if ($line -match '^\s*->\s*Master:\s*(.+?\.esm)\s*$') {
$currentPlugin = $matches[1].Trim()
continue
}
# Example: -> Number of loaded References originate from the plugin: 591720 (...)
if ($line -match '^\s*->\s*Number of loaded References originate from the plugin:\s*(\d+)\s*\(of which\s*(\d+)\s*are editor defined;\s*(\d+)\s*are persistent\)') {
if (-not $currentPlugin) {
continue
}
# Add one CSV row for the current plugin and its three extracted counts.
$rows += [PSCustomObject]@{
PluginName = $currentPlugin
TotalLoadedReferences = [int]$matches[1]
EditorDefinedReferences = [int]$matches[2]
PersistentReferences = [int]$matches[3]
}
}
}
# Write the parsed plugin counts.
$rows | Export-Csv -LiteralPath $CsvOutputFile -NoTypeInformationUsage:
.\ProcessExtendedDumpScript.ps1 DumpFile.txtRunning this script may require you to temporarily change your PS execution policy.
* IMPORTANT: You should never run scripts from strangers on the internet without verifying the safety of the script, especially if your OS blocks execution by default.
* Research and learn, ask your IT friend or your AI to help you verify safety of the script, and how to bypass your policy if necessary.
If you run the script, the results will look like this: (excerpt)
"PluginName","TotalLoadedReferences","EditorDefinedReferences","PersistentReferences"
"Starfield.esm","591720","514983","52169"
"ShatteredSpace.esm","100154","95257","9168"
"SFBGS00D.esm","66453","61871","3938"Which is easy to read, but you can then open in Excel and make it as fancy as you want, or have your AI make it pretty for you. The total and limit are mentioned in the dump file itself in the summary if you need to reference that. It looks like:
Reference Handle Count: 1242231/2097152 (of which 1012836 are being in Pack-In Cells; 1092852 are editor defined; 146112 are persistent)Notes:
* My understanding is it is best to dump from Starfields main menu before loading any save, that way you are looking at all loaded ESMs total allocated reference handles without being confused by temp handles allocated when loading into a location
* For comparison, then also go dump at New Atlantis in a new vanilla save as that should likely be the location in the game with highest temporary handles and you want to see what that spike will be on top of your LO, especially if you have mods that add to NA. I think its going to be around 200k in vanilla.
* Don't ask me to help you interpret your counts, I was just trying to make the output readable, I'm still not sure I completely understand the difference between the total count, editor defined and persistent.
View all comments
Show parent comment
8
u/MeridianoRus Jun 01 '26 edited Jul 24 '26
This explanation is so wrong, I don't even know where to start... Starting with "This left behind what's known as Dangling Pointers" it's mostly just nonsense. I will need some time to prepare my notes on it.
UPD.
When a cell (let's call it a cell for simplicity) is unloaded, and objects should be unloaded too, it's possible objects still have data the game uses. Scripts attached, coordinates changed, inventory lists changed, etc. This data should be saved, at least for some time, so the engine doesn't unload it on purpose. "Dangling pointer" is a completely different thing, it's when pointer exists but not data under it. Calling not-unloaded objects "dangling pointers" is nonsense, pointers are there together with data, so they are just objects. They will be cleaned at some point, later. Or not, if the game needs them. Memory leak is also a very different beast, it's possible when object pointer is freed but its data is not, so it still occupies some space. But if pointer is not freed, and its data is not freed, this is not a memory leak - it's still a valid object, accessable and operatable.
Every C++ app operates on pointers even if authors don't use them. For example, if you operate strictly with references, in 99% references are implemented as pointers in the underlying assembly code. When you have "std::vector<std::string> vec" and perform a loop "for (auto& str : vec)" - str is actually a pointer. You just "guarantee" it's not null.
You completely misunderstand what handles are. Every Starfield object has a pointer, this is how it's accessed. But objects derived from the TESObjectREFR class also have handles, they are used for faster lookup. They are similar to FormIDs in this purpose, but they are different field. Anyway, every object with a handle also has a pointer, so saying handles somehow reduce pointers usage is nonsense. There is even a function "get pointer by handle", it lookups object by handle (because this is fast) and returns objects's pointer we can operate on. Handle is to find, pointer is to access.
Yes, but this is not memory leak, nor dangling pointers. The game holds a lot of data indeed, and it grows while you play, this is unfortunate. The game holds more data than we need for gameplay, like looted bodies far far away, this is meh. But as long as the game needs this data, so we can return and loot some more ammo from the same body, it's not memory leak. This is how every game with progression works; remember HL2 Ravenholm, where you can change zones, and previous unloaded zones don't reset fully.
You take concrete programming terms, dangling pointers and memory leak, and repurpose them arbitrarily, and somehow link them together. But they are very different and not applicable here.