Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fork_exec: cannot allocate memory #26

Open
virtuald opened this issue Mar 8, 2020 · 1 comment
Open

fork_exec: cannot allocate memory #26

virtuald opened this issue Mar 8, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@virtuald
Copy link
Member

virtuald commented Mar 8, 2020

  File "robot.py", line 59, in createObjects
    wpilib.CameraServer.launch()
  File "/usr/local/lib/python3.8/site-packages/wpilib/cameraserver.py", line 83, in launch
    proc = subprocess.Popen(
  File "/usr/local/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.8/subprocess.py", line 1637, in _execute_child
    self.pid = _posixsubprocess.fork_exec(
OSError: [Errno 12] Cannot allocate memory

This user is importing rev, ctre, numpy, and lots of things, and my belief is that when we do a subprocess.run it's copying the entire process memory space (because that's what fork does on linux? -- though I thought it was supposed to be copy on write?), and failing to do so.

A workaround is to put the cameraserver launch at the beginning of the robot.py before anything else is imported. A bit of a hack, but it works. Need to think about a better way to address this.

@virtuald virtuald added the bug Something isn't working label Mar 8, 2020
@auscompgeek
Copy link
Member

because that's what fork does on linux? -- though I thought it was supposed to be copy on write?

I'm pretty sure it is, but I presume Linux reserves additional memory space so you don't randomly OOM by simply writing to your "existing" memory.

@virtuald virtuald transferred this issue from robotpy/robotpy-cscore Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants