0

I have code that is trying to serialize a very large Java object through Spring into Redis. For most objects, this works fine. For a few very large objects it results in StackOverflowError. I'm trying to figure out if I can tune for this, but I can't find a way to ask the JVM "how big is the default stack"?

Is there some System.getDefaultStackSize() or System.getProperty("Xss") that I can leverage here?

Bob Kuhar
  • 10,838
  • 11
  • 62
  • 115
  • It is possible to get the value of `ThreadStackSize` JVM option like in [this answer](https://stackoverflow.com/a/67723382/3448419). How would this help you though? – apangin Jul 18 '22 at 16:01
  • @apangin Hmm. `2022-07-18 09:08:50.585 INFO [mbom-service,,,] 7209 --- [ main] a.repositories.redis.MbomRedisRepository : -Xss is 0` when `.getVMOption("CompilerThreadStackSize")`. This is rather obscure – Bob Kuhar Jul 18 '22 at 16:10
  • 1
    You still didn’t say how this value would help you. What are you going to do with that value? – Holger Jul 18 '22 at 16:55
  • @Holger Sorry. I'm trying to figure out what the default stacksize is so I can set a larger one to see if I can get my "mega object" to serialize into Redis through Spring's RedisTemplate. Its not looking good. I'm at -Xss3m right now and it takes 6+ minutes, but eventually StackOverflowError – Bob Kuhar Jul 18 '22 at 17:21
  • 1
    If you have that option, you can do it regardless of what default stack size you have. But keep in mind that every persistence mechanism has two sides. If you write an object using an extraordinarily large stack, the reading side very likely also needs an extraordinarily large stack… – Holger Jul 18 '22 at 17:47

0 Answers0