The Go runtime can only attempt to return the memory. Ultimately, the OS decides when to take the freed memory away from the process.
BTW, I hope this code is only for learning or research. If you think you need FreeOSMemory in production you certainly have a deeper problem behind that to solve.
Note that if you want to free memory up for some reason, you’ll want to have the Go runtime GC and free memory to the OS, then have the OS free up the memory. Doing it the other way around isn’t going to work as well.