title: How using BigDecimal would affect application performance?
body: <p>I want to use BigDecimal to represent arbitrary precision numbers like prices and amounts in a low-latency trading application with thousands of orders and execution reports per second. </p>
  
  <p>I won't be doing many math operations on them, so the question is not about performance of the BigDecimal per se, but rather about how large volumes of BigDecimal objects would affect performance of the application.</p>
  
  <p>My concern is that huge amount of short-lived BigDecimal objects will put a strain on a GC and result in larger Stop-The-World pauses in CMS collector - and this is definitely what I would like to avoid.</p>
  
  <p>Can you please confirm my concerns and suggest alternatives to using BigD? Also, if you think my concerns are wrong - please explain why.</p>
  
  <p><strong>Update</strong>:</p>
  
  <p>Thanks for all who answered. I am now convinced that using BigDecimal will hurt latency of my application (even though I still plan to measure it).</p>
  
  <p>For the time being we decided to stick with "very non-OOP" solution (but without accuracy hit) - use two <code>int</code>s, one for mantissa and another one for exponent. Rationale behind this is that primitives are placed on stack, not heap, and hence are not subject to garbage collection.</p>