{"action":"created","issue":{"url":"https://api.github.com/repos/osmcode/libosmium/issues/150","repository_url":"https://api.github.com/repos/osmcode/libosmium","labels_url":"https://api.github.com/repos/osmcode/libosmium/issues/150/labels{/name}","comments_url":"https://api.github.com/repos/osmcode/libosmium/issues/150/comments","events_url":"https://api.github.com/repos/osmcode/libosmium/issues/150/events","html_url":"https://github.com/osmcode/libosmium/issues/150","id":149778025,"number":150,"title":"osm2pgsql crashes with \"std::bad_alloc\" inside libosmium","user":{"login":"Zverik","id":766031,"avatar_url":"https://avatars.githubusercontent.com/u/766031?v=3","gravatar_id":"","url":"https://api.github.com/users/Zverik","html_url":"https://github.com/Zverik","followers_url":"https://api.github.com/users/Zverik/followers","following_url":"https://api.github.com/users/Zverik/following{/other_user}","gists_url":"https://api.github.com/users/Zverik/gists{/gist_id}","starred_url":"https://api.github.com/users/Zverik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zverik/subscriptions","organizations_url":"https://api.github.com/users/Zverik/orgs","repos_url":"https://api.github.com/users/Zverik/repos","events_url":"https://api.github.com/users/Zverik/events{/privacy}","received_events_url":"https://api.github.com/users/Zverik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-20T14:06:00Z","updated_at":"2016-04-20T15:34:54Z","closed_at":null,"body":"I'm trying to import a [700 MB pbf file](http://tile.osmz.ru/tileosmz.osm.pbf) to pgsql with osm2pgsql on a virtual machine with 1 GB of memory and 1 GB of swap. This fails, though it did work with much earlier versions of osm2pgsql, like 0.86.\r\n\r\nWhat can I do to further debug this, or to get rid of the error?\r\n\r\nThanks.\r\n\r\n```\r\nzverik@tile:~$ gdb osm2pgsql                  \r\nGNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1\r\n(gdb) set args  --slim -d gis -C 600 -S veloroad.style tileosmz.osm.pbf\r\n(gdb) r\r\nStarting program: /usr/local/bin/osm2pgsql --slim -d gis -C 600 -S veloroad.style tileosmz.osm.pbf\r\n[Thread debugging using libthread_db enabled]\r\nUsing host libthread_db library \"/lib/x86_64-linux-gnu/libthread_db.so.1\".\r\nosm2pgsql version 0.91.0-dev (64 bit id space)\r\n\r\nUsing built-in tag processing pipeline\r\nUsing projection SRS 3857 (Spherical Mercator)\r\nSetting up table: planet_osm_point\r\nSetting up table: planet_osm_line\r\nSetting up table: planet_osm_polygon\r\nSetting up table: planet_osm_roads\r\nAllocating memory for dense node cache\r\nAllocating dense node cache in one big chunk\r\nAllocating memory for sparse node cache\r\nSharing dense sparse\r\nNode-cache: cache=600MB, maxblocks=9600*65536, allocation method=11\r\nMid: pgsql, scale=100 cache=600\r\nSetting up table: planet_osm_nodes\r\nSetting up table: planet_osm_ways\r\nSetting up table: planet_osm_rels\r\n\r\nReading in file: tileosmz.osm.pbf\r\nUsing PBF parser.\r\n[New Thread 0x7fffbfa1b700 (LWP 4772)]\r\n[New Thread 0x7fffbf21a700 (LWP 4773)]\r\n[New Thread 0x7fffbea19700 (LWP 4774)]\r\nProcessing: Node(18190k 129.0k/s) Way(0k 0.00k/s) Relation(0 0.00/s)[Thread 0x7fffbfa1b700 (LWP 4772) exited]\r\n[New Thread 0x7fffbea19700 (LWP 4774)]\r\nProcessing: Node(18190k 129.0k/s) Way(0k 0.00k/s) Relation(0 0.00/s)[Thread 0x7fffbfa1b700 (LWP 4772) exited]\r\n[Thread 0x7fffbf21a700 (LWP 4773) exited]\r\nterminate called after throwing an instance of 'std::bad_alloc'\r\n  what():  std::bad_alloc\r\n\r\nProgram received signal SIGABRT, Aborted.\r\n0x00007ffff5f84cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56\r\n56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.\r\n(gdb) up\r\n#1  0x00007ffff5f880d8 in __GI_abort () at abort.c:89\r\n89      abort.c: No such file or directory.\r\n#2  0x00007ffff688f535 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6\r\n#3  0x00007ffff688d6d6 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6\r\n#4  0x00007ffff688d703 in std::terminate() () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6\r\n#5  0x00007ffff688d976 in __cxa_rethrow () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6\r\n#6  0x000000000049735f in read (this=0x7fffffffdea0) at /home/zverik/src/osm2pgsql/contrib/libosmium/osmium/io/reader.hpp:341\r\n341                         throw;\r\n#7  osmium::io::InputIterator<osmium::io::Reader, osmium::memory::Item>::update_buffer (this=0x7fffffffdd40) at /home/zverik/src/osm2pgsql/contrib/libosmium/osmium/io/input_iterator.hpp:68\r\n68                          m_buffer = std::make_shared<osmium::memory::Buffer>(std::move(m_source->read()));\r\n#8  0x0000000000487f3b in operator++ (this=0x7fffffffdd40) at /home/zverik/src/osm2pgsql/contrib/libosmium/osmium/io/input_iterator.hpp:103\r\n103                         update_buffer();\r\n#9  apply<osmium::io::InputIterator<osmium::io::Reader>, parse_osmium_t> (end=..., it=...) at /home/zverik/src/osm2pgsql/contrib/libosmium/osmium/visitor.hpp:235\r\n235             for (; it != end; ++it) {\r\n#10 apply<osmium::io::Reader, parse_osmium_t> (c=...) at /home/zverik/src/osm2pgsql/contrib/libosmium/osmium/visitor.hpp:243\r\n243             apply(std::begin(c), std::end(c), handlers...);\r\n#11 parse_osmium_t::stream_file (this=this@entry=0x7fffffffe260, filename=\"tileosmz.osm.pbf\", fmt=\"auto\") at /home/zverik/src/osm2pgsql/parse-osmium.cpp:123\r\n123         osmium::apply(reader, *this);\r\n#12 0x00000000004612d3 in main (argc=<optimized out>, argv=<optimized out>) at /home/zverik/src/osm2pgsql/osm2pgsql.cpp:88\r\n88                  parser.stream_file(filename, options.input_reader);\r\n```"},"comment":{"url":"https://api.github.com/repos/osmcode/libosmium/issues/comments/212480342","html_url":"https://github.com/osmcode/libosmium/issues/150#issuecomment-212480342","issue_url":"https://api.github.com/repos/osmcode/libosmium/issues/150","id":212480342,"user":{"login":"Zverik","id":766031,"avatar_url":"https://avatars.githubusercontent.com/u/766031?v=3","gravatar_id":"","url":"https://api.github.com/users/Zverik","html_url":"https://github.com/Zverik","followers_url":"https://api.github.com/users/Zverik/followers","following_url":"https://api.github.com/users/Zverik/following{/other_user}","gists_url":"https://api.github.com/users/Zverik/gists{/gist_id}","starred_url":"https://api.github.com/users/Zverik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zverik/subscriptions","organizations_url":"https://api.github.com/users/Zverik/orgs","repos_url":"https://api.github.com/users/Zverik/repos","events_url":"https://api.github.com/users/Zverik/events{/privacy}","received_events_url":"https://api.github.com/users/Zverik/received_events","type":"User","site_admin":false},"created_at":"2016-04-20T15:34:54Z","updated_at":"2016-04-20T15:34:54Z","body":"Even then, there should be a better way to report an out of memory error."}}