In computing, the term memory is somewhat loosely defined. Most of the time, it will refer to RAM. In some cases, however, storage devices may be referred to as memory devices. In a technical sense, this isn’t even wrong. Storage devices are a form of non-volatile memory. To maintain clarity, however, they are typically distinctly referred to as storage rather than memory. Any application will require both storage space and memory space.
Memory, or RAM, is used to store data for the currently running applications. The CPU actively reads and uses this data to run the software. It is, therefore, important to be sure that the data in memory is accurate and that any changes to that data are precisely targeted. Shadow memory is a technique used to track and monitor memory usage during program execution. It utilizes a series of shadow bytes that map to bits or bytes of memory. The exact functionality can vary, but it could be viewed as somewhat analogous to a software implementation of ECC.
Shadow memory is less a type of memory than a use of memory. It shadows, or duplicates, a section of memory being tested. It’s key to note that this duplication may not be a bit-for-bit replication. Instead, it may be used more like ECC or a checksum to verify that no unexpected changes have occurred.
Uses for Shadow Memory
Shadow memory is typically used to help to identify the mishandling of memory. Incorrect memory management can lead to many forms of unintended behavior. Quite often, it leads to a crash. Memory corruption, however, can take the form of buffer overflows, resulting in arbitrary code execution. Identifying and replicating these memory issues in large and complex applications can be difficult and time-consuming.
One of the issues encountered is that crashing closes the application, releasing the data from memory. Shadow memory can be independent of the tested; therefore, crashing, application, and so can persist. This allows a post-crash analysis of the memory as it was at the moment of the crash rather than relying on a stack trace which may not provide all the details necessary to identify and resolve the root cause of the issue.
The software “Memcheck” in the “Valgrind” suite uses it for this purpose. Doing so provides a significant performance penalty and significantly increases the RAM requirements. Other products that also utilize shadow memory exist. AddressSanitizer, for example, has a notably lower performance and RAM requirement penalty, though it still consumes extra memory.
Shadow RAM
Shadow RAM has a similar name but a different function. It is a process of reading data from slow media, typically ROM, to RAM to run the software. Shadow RAM is commonly used for the BIOS and may be found as a Shadow BIOS setting. This essentially functions as a small RAM disk and can provide performance improvements.
Typically, however, the BIOS hands off to an operating system that sees no benefit from using a Shadow RAM-loaded Shadow BIOS. An affected operating system would lose the amount of RAM used to hold the Shadow BIOS. Typically, this won’t significantly affect performance but can negatively impact performance.
Conclusion
Shadow memory is a method of utilizing system RAM. It shadows a specific memory section, often that of a program experiencing memory issues, to identify and remediate the cause. The shadowing may be a direct bit-for-bit replication or an indirect shadowing depending on the precise nature of the software performing the shadowing. Shadow memory should not be confused with Shadow RAM, a method of loading non-RAM data into RAM to run the software from there.
Did this help? Let us know!