Skip to content

Instantly share code, notes, and snippets.

@f3nry
Last active December 12, 2015 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f3nry/4753221 to your computer and use it in GitHub Desktop.
Save f3nry/4753221 to your computer and use it in GitHub Desktop.
Initializing an array and setting an incredibly high index causes Ruby to immediately use all of the available memory due to initializing all previous values in the array to the high index. I'm using ruby 1.9.3p286 on a Macbook with 8 gb of ram.
some_array = []
some_array[Time.now.to_i] = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment