Maximum asset file limit in windows? MC freezes

Skip to first unread message

Ryan McQuaid

Sep 22, 2023, 8:22:15 PM9/22/23
to MPF Users
Hi all,

I'm trying to bulletproof the existing code for Sonic so I can tour it on a few more shows. A lot of people have told me they are sad they never got a chance to play. I have a problem that I think I'm on the right track to fixing but I've run out of ideas on how to implement the solution. 

Basically, if I load too many assets (over 1000), the mc will freeze and crash. This currently happens at startup because I am preloading all assets. I've had nothing but problems with game performance when trying to load things on_demand and I have certain assets I can't load on demand due to the custom asset manager I'm using. I have a crazy fast m.2 SSD and I've been down that road before. I just want to preload everything and not worry. Anyways, if I remove 30 or so files from loading it stops breaking. File size doesn't matter, only count. I'd just find a way to trim 30 or so files out, but I want to add more. Ive done research and found that 1024 is a common limit on the number of open files an application can access at the  os level and that seems to be the issue I'm running into. There is an old post about this being an issue on linux here:

Apparently in Linux this is an easy fix, but is somewhat more complicated in windows. A stack overflow post appears to detail the equivalent setting as win32file._setmaxstdio (image attached)  Ive tried adding this to along with the proper import, and while it didn't crash anything it didn't help either. I've reached the end of my ability to troubleshoot and implement the fix I may have found as I'm just not a software guy even though I pretend to be sometimes. 

Avery Tummons

Sep 22, 2023, 9:43:38 PM9/22/23
No idea, but did a quick search. I know MC is compiled on C and Cython. Wonder if you need that for python and this for C. Maybe one is trumping the other. Can you test by printed out to logs and ensure the value is actually being set. Or debug through to check.

import ctypes
print("Before: {}".format(ctypes.windll.msvcrt._getmaxstdio()))
print("After: {}".format(ctypes.windll.msvcrt._getmaxstdio()))

Sent from my iPhone

On Sep 22, 2023, at 7:22 PM, Ryan McQuaid <> wrote:

Hi all,
You received this message because you are subscribed to the Google Groups "MPF Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
Reply all
Reply to author
0 new messages