I have a 2019 MacBook Pro i9 with 64gb of RAM. Last night I got a kernel panic due to memory corruption (just the one time). So, today, I wrote a tiny program in C++ to allocate and probe a large amount of memory, setting memory locations with alternating 0's and 0xff's, then it checks that the memory remained the same. Here it is:
#include<stdlib.h>
#include<stdio.h>
int main(int argc,char **argv)
{
printf("Allocating...\n");
unsigned char* mem = (unsigned char*)malloc(52949672960);
if(!mem) { printf("alloc error!\n"); return 1; }
printf("Filling memory...\n");
for(long i=0;i<52949672960;i+=2) { mem[i]=255; mem[i+1]=0; }
printf("Testing memory...\n");
for(long i=0;i<52949672960;i+=2) {
if(mem[i]!=255) printf("ERROR!! Loc %lu was %d instead of %d\n",i,mem[i],255);
if(mem[i+1]!=0) printf("ERROR!! Loc %lu was %d instead of %d\n",i+1,mem[i+1],0);
}
free(mem);
printf("Complete!\n");
return 0;
}
To my horror, I kept getting an error on 1 memory location, such as:
stormlord@MacBook-Pro mem % ./test
Allocating...
Filling memory...
Testing memory...
ERROR!! Loc 917863483 was 1 instead of 0
Complete!
I noticed a theme, the address (917863483, in this case) is 0x36B57C3B in hex, which ends in C3B and this was always the case - the addresses always end in C3B and it always goes from a 0 to a 1. So I'm thinking it's the same physical memory location but it shows up in different places in my array because, obviously, the physical memory isn't going to line up the same every time. (Side note: I realize my test should probably go over the same memory and write/verify the opposite bytes in a second pass).
I read online that restarting the computer while holding OPT + CMD + R + P will zap PRAM and it could help with general hardware issues. My tests have been passing since I did this but I'm still not comfortable. Does this sound like hardware damage? Or am I in the clear?