Support #1254
St9bad_alloc errors plotting in Python
100%
Description
I'm getting the dreaded: "terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc" (memory related) errors when trying to trying to loop over my virtual planes & make plots, (the same approach given in Xboa Example 2) e.g.:
Bunch.root_graph(bunch_list, 'mean', ['z'], 'mean', ['x'], 'm', 'mm')
Bunch.root_graph(bunch_list, 'mean', ['z'], 'mean', ['pz'], 'm', 'mm')
Bunch.root_graph(bunch_list, 'mean', ['z'], 'mean', ['energy'], 'm', 'mm')
Bunch.root_graph(bunch_list, 'mean', ['z'], 'mean', ['time'], 'm', 'mm')
Bunch.root_graph(bunch_list, 'mean', ['z'], 'beta', ['x','y'], 'm', 'mm')
Bunch.root_graph(bunch_list, 'mean', ['z'], 'emittance', ['x','y'], 'm', 'mm')
etc
I get the same error if I simply fill arrays, e.g.:
for Plane in range( 0, len(bunch_list)-1 ):
my_bunch = bunch_list[Plane]
_x= round(my_bunch.get('mean', ['x'] ), 2)
_y= round(my_bunch.get('mean', ['y'] ), 2)
etc
my simulations have 10,000 muons, and >100 planes which probably isn't helping the memory side of things...I'm not well versed in Python at all, any advice on how to get round this?
Thanks,
Tim
Files
Updated by Rogers, Chris over 10 years ago
- Target version set to Future MAUS release
Which version of xboa are you using? Can you attach the full script?
Cheers
Updated by Rogers, Chris over 10 years ago
Note xboa version is
import xboa.Common print xboa.Common.xboa_version
Updated by Carlisle, Timothy over 10 years ago
Hey Chris,
I'm using 0.15. Example 2 script attached (matplot stuff removed). I've added 2 statements to output beta(z) and emittance(z), which are producing the errors.
Thanks
Updated by Rogers, Chris over 10 years ago
I had a memory leak "blitz" in 0.15.1, available here:
http://micewww.pp.rl.ac.uk/maus/xboa/
See if that fixes your problem.
To install, follow instructions here
Updated by Rogers, Chris over 10 years ago
Also, if you have a record of the output could you send it through to me?
Updated by Carlisle, Timothy over 10 years ago
Ah great thanks, installing new Xboa at the moment.
Do you mean a proper error log output?
Updated by Carlisle, Timothy over 10 years ago
Do I need to re-config Maus first? It can't find python it seems...vaguely remember this happening before. Maus0.5 has Python-2.7.2 bundled I think.
~/maus0.5_orig/third_party/build/xboa-0.15.1 python setup.py build
running build
running build_py
running build_ext
building 'xboa.core.Bunchcore' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/carlisle/maus0.5_orig/third_party/install/include/python2.7 -c xboa/core/Bunchcore.c -o build/temp.linux-x86_64-2.7/xboa/core/Bunchcore.o
gcc -pthread -shared build/temp.linux-x86_64-2.7/xboa/core/Bunchcore.o -L/home/carlisle/maus0.5/third_party/install/lib -lpython2.7 -o build/lib.linux-x86_64-2.7/xboa/core/Bunchcore.so
/usr/bin/ld: cannot find -lpython2.7
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Updated by Rogers, Chris over 10 years ago
I was going to phone but looks like they took the contact details off the John Adams website(!)
I noticed you had the path as:
/home/carlisle/maus0.5
and in some places:
/home/carlisle/maus0.5_orig
looks like this is causing problems.
Updated by Rogers, Chris over 10 years ago
- Category set to bin(aries)
- Status changed from Open to Closed
- % Done changed from 0 to 100
Resolved with phone call to Tim. Looks like he encountered memory problems associated with bugs in 0.15.0 which were fixed in 0.15.1 - talked Tim through the installation process, following which things looked okay.