<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16437"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial>Martin,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial>Can't remember last time I had that error, but Ihave seen it 
before.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial>I think the cause is one of two reasons</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial>Corrupted location on disk -- usually involving a geometry 
record.  That is a pain to figure out.  I think I ended up doing 
limits to find the bad record and then deleted it or relaoaded the table 
skipping that record.  That case usually screws up your backup so you can 
tell if your backups are failing if this is the issue since the backup would try 
to traverse the record and fail with a bad alloc.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial>or</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=763520819-23102011><FONT color=#0000ff 
size=2 face=Arial>Bad geometry that causes infinite memory 
allocation.</FONT></SPAN></DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 face=Arial>You 
might want to try upgrading your PostGIS to latest 1.4 minor (1.4.0 is not the 
latest stable release of 1.4)</FONT></SPAN></DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 face=Arial>You 
might also want to upgrade your Geos.  I would try to go to 3.2.3 if at all 
possible.  I think several memory issues were fixed in 3.2 and may not have 
been back-ported to 3.1 because the code changed too much.</FONT></SPAN></DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 face=Arial>Strk 
might have a better idea.</FONT></SPAN></DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 face=Arial>Hope 
that helps,</FONT></SPAN></DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 
face=Arial>Regina</FONT></SPAN></DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 face=Arial><A 
href="http://www.postgis.us">http://www.postgis.us</A></FONT></SPAN></DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 
face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=763520819-23102011><FONT color=#0000ff size=2 
face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><BR></DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px" 
dir=ltr>
  <DIV dir=ltr lang=en-us class=OutlookMessageHeader align=left>
  <HR tabIndex=-1>
  <FONT size=2 face=Tahoma><B>From:</B> 
  postgis-users-bounces@postgis.refractions.net 
  [mailto:postgis-users-bounces@postgis.refractions.net] <B>On Behalf Of 
  </B>Martin Güther<BR><B>Sent:</B> Sunday, October 23, 2011 7:03 
  AM<BR><B>To:</B> postgis-users@postgis.refractions.net<BR><B>Subject:</B> 
  [postgis-users] memory bug in postgis query<BR></FONT><BR></DIV>
  <DIV></DIV>
  <DIV><SPAN style="FONT-SIZE: 13px" class=Apple-style-span>Hi guys,<BR>i 
  recently asked the same question on the postgresql mailing list but they 
  forwarded me to this mailing list.</SPAN></DIV>
  <DIV><SPAN style="FONT-SIZE: 13px" class=Apple-style-span>I really hope you 
  can help me :)</SPAN></DIV>
  <DIV><BR></DIV>
  <DIV><SPAN style="FONT-SIZE: 13px" class=Apple-style-span>on a test maschine 
  from my university i'm running into a weird problem (i attached detail 
  info):<BR><BR>A running postgis query eats more and more memory.(seen in 
  htop) </SPAN></DIV>
  <DIV><SPAN style="FONT-SIZE: 13px" class=Apple-style-span>It'll 
  start using virtual memory and after eating up that one, too, postgres 
  will<BR>crash with:<BR><BR>psql:/home/mguether/sql/benchmark.sql:6: NOTICE: 
   std::bad_alloc<BR>psql:/home/mguether/sql/benchmark.sql:6: ERROR: 
   GEOS intersects()<BR>threw an error!<BR><BR>once it gave me 
  an<BR>psql:/home/mguether/sql/benchmark.sql:6: ERROR:  out of 
  memory<BR>DETAIL:  Failed on request of size 182949.<BR><BR>after the 
  crash, all memory/swap is free again, so it really is postgres :)<BR><BR>i 
  don't really know how to debug it any more detailed or fix this<BR>issue in 
  any way.<BR><BR>Does anyone here have a hint, where the issue might 
  be?<BR><BR>thanks,<BR></SPAN><SPAN style="FONT-SIZE: 13px" 
  class=Apple-style-span>martin<BR><BR><BR><BR><BR><BR><BR><BR>here some 
  information:<BR><BR>the maschine:<BR>16 GB RAM, i7 4cores x64 
  2.6.32-21-server ubuntu<BR><BR>installed postgres:<BR>psql (PostgreSQL) 
  8.4.9<BR>including postgis<BR>POSTGIS="1.4.0" GEOS="3.1.0-CAPI-1.5.0" 
  PROJ="Rel. 4.7.1, 23 September<BR>2009" USE_STATS<BR><BR>i changed two 
  parameters from the default config:<BR>shared_buffers = 512MB<BR>work_mem = 
  256MB<BR><BR>using osm2pgsql I important some GEO data, and want to execute 
  this query:<BR><BR>SELECT a.osm_id, w.osm_id FROM "planet_osm_line" 
  w,<BR>"planet_osm_polygon" a WHERE ST_Intersects(w.way,a.way) AND 
  w.highway<BR>IS NOT NULL;<BR><BR>the EXPLAIN gives me:<BR><BR>Nested Loop 
   (cost=0.00..26427424.16 rows=1511021 width=8)<BR>  Join Filter: 
  _st_intersects(w.way, a.way)<BR>  ->  Seq Scan on planet_osm_line 
  w  (cost=0.00..49213.10<BR>rows=1137488 width=837)<BR>    
      Filter: (highway IS NOT NULL)<BR>  ->  Index Scan 
  using osm_areas_index on planet_osm_polygon a<BR>(cost=0.00..23.10 rows=6 
  width=824)<BR>        Index Cond: (w.way && 
  a.way)<BR>(6 rows)</SPAN></DIV>
  <DIV></DIV>
  <DIV></DIV>
  <DIV></DIV>
  <DIV></DIV>
  <DIV></DIV>
  <DIV><BR></DIV>
  <DIV><BR></DIV>
  <DIV><BR></DIV>
  <DIV><BR></DIV>
  <DIV><BR></DIV>
  <DIV><BR></DIV>
  <DIV><SPAN style="FONT-SIZE: 13px" class=Apple-style-span><BR></SPAN></DIV>
  <DIV></DIV></BLOCKQUOTE></BODY></HTML>