My algorithm needs to use more stack space than allowed by default. Do I have to increase the stack space on every machine, or is there a way to include it in the class so it will run smoothly on each machine.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your latter approach won’t work – the stack space is a startup parameter, which is used to allocate space to the Java process itself.
By the time everything has been set up to load and execute the class, by definition the process already exists and its stack size has already been determined. You can’t modify
Xssat runtime.Usually what you’d do though is distribute a startup script which launches your application with appropriate memory parameters. How is your class being invoked? If it’s a library then it’s the application’s job to ensure enough memory is allocated, arguably you can just list it as a requirement in your documentation.
In an extreme case you could use
Processto spawn a completely new Java process with the startup parameters you desire – however this would be very error prone, would require an assumption thatjavawas on the path (or that the same directory structure exists everywhere), that you have permissions to create new processes, that sufficient memory/filehandles exist for this new process, etc. It isn’t something I’d want to do, but if you exhaust all other options it might tide you over in a pinch.