Is there a limit to the amount of data that can be stored in an environment variable on Linux, and if so: what is it?
For Windows, I've found following KB article which summarizes to:
Windows XP or later: 8191 characters
Windows 2000/NT 4.0: 2047 characters
Best Answer
I don't think there is a per-environment variable limit on Linux. The total size of all the environment variables put together is limited at
execve()
time. See "Limits on size of arguments and environment" here for more information.A process may use
setenv()
orputenv()
to grow the environment beyond the initial space allocated by exec.Here's a quick and dirty program that creates a 256 MB environment variable.