# Max bin number in histogramm

**URL:** <https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971>\
**Category:** ROOT\
**Created:** [July 28, 2014, 8:02am UTC](https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971 "2014-07-28T08:02:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![router](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@router](https://root-forum.cern.ch/u/router)\
**Post date:** [July 28, 2014, 8:02am UTC](https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971/1 "2014-07-28T08:02:07Z")

</div>

Hallo rooters!

I’ve got a histogramm with 1.9845e+6 entries I want to plot in a TH1F.

TH1F \*h1 = new TH1F(“h1”,“title”,p,0,nentries).

When I replace p with nentries, the error “type G\_\_exception” occurs. But when I decrease the number of bins, i.e. p = nentries/2, it works.

Is there a limitation of max. bin-entries?

Thanks!

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 28, 2014, 8:10am UTC](https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971/2 "2014-07-28T08:10:00Z")

</div>

Check how much RAM you are trying to allocate (if “p” is big …).  
For a single TH1F histogram, if p = nentries = 1.9845e+6 then there should be no problem (the amount of RAM used by such a TH1F would be something like 8 MB without “Sumw2” and something like 24 MB with “Sumw2”).

---

<div class="post-metadata">

**Author:** ![router](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@router](https://root-forum.cern.ch/u/router)\
**Post date:** [July 28, 2014, 8:37am UTC](https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971/3 "2014-07-28T08:37:47Z")

</div>

I must edit my post. The error only occurs when I want to draw the hist, writing isn’t a problem. But when I want to open the hist with the root browser nothing happens.  
Methods like “inspect” works fine, all written entries are shown correctly. When I click on “draw panel” or any other method which would show me the hist, root crashes.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 28, 2014, 8:52am UTC](https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971/4 "2014-07-28T08:52:08Z")

</div>

The below macro works fine for me …

```auto
{
  Int_t nentries = 1984500;
  Int_t p = nentries;
#if 0 /* 0 or 1 */
  TH1::SetDefaultSumw2(); // note: makes drawing much longer
#endif /* 0 or 1 */
  TH1F *h1 = new TH1F("h1", "title", p, 0, nentries);
  for (Int_t i = 0; i < nentries; i++)
    h1->Fill( gRandom->Rndm() * nentries, gRandom->Rndm() );
  h1->Draw();
}

```

---

<div class="post-metadata">

**Author:** ![router](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@router](https://root-forum.cern.ch/u/router)\
**Post date:** [July 28, 2014, 10:34am UTC](https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971/5 "2014-07-28T10:34:44Z")

</div>

Thank you, this works fine. But my entry number is 1.9845e+7. This was my fault, sorry ☹ . In this case your example doesn’t work, too.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 28, 2014, 11:19am UTC](https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971/6 "2014-07-28T11:19:04Z")

</div>

So, I tried my above macro with p = nentries = 1.9845e+7 and I get no problems (ROOT v5-34-19 / Linux x86\_64 gcc 4.8.2).

Try to check:  
[bash]$ ulimit -S -a  
[bash]$ ulimit -H -a  
[tcsh]$ limit  
[tcsh]$ limit -h  
and make sure that you do not exceed any limits (e.g. try to increase the “stack size” soft limit).

---

<div class="post-metadata">

**Author:** ![router](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/9de053/32.png) [@router](https://root-forum.cern.ch/u/router)\
**Post date:** [July 29, 2014, 5:58am UTC](https://root-forum.cern.ch/t/max-bin-number-in-histogramm/17971/7 "2014-07-29T05:58:33Z")

</div>

Is there any possibiliy to do this on windows?
