MemoryError at /render/

Asked by keeps

Installing graphite for the first time on a clean system. After satisfying all requirements, and getting it to run ( whisper db's are being updated with data according to the logs, and the front end displays), I cant create images.

Initially, i was getting a internal 500 error, template not found on the logs, after creating this template, I'm getting this.

MemoryError at /render/
Request Method: GET
Request URL: http://10.100.1.50/render/
Exception Type: MemoryError
Exception Value:
Exception Location: /usr/local/graphite//webapp/web/render/glyph.py in getExtents, line 153

And no images show.

Am I missing anything? i even tried upgrading to the new dev version on source control, and nothing, still the same error.

Please help :)

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
keeps
Solved:
Last query:
Last reply:
Revision history for this message
keeps (jfrias-gmail) said :
#1

    * /usr/lib/python2.4/site-packages/django/core/handlers/base.py in get_response
        70. # Apply view middleware
        71. for middleware_method in self._view_middleware:
        72. response = middleware_method(request, callback, callback_args, callback_kwargs)
        73. if response:
        74. return response
        75.
        76. try:
        77. response = callback(request, *callback_args, **callback_kwargs) ...
        78. except Exception, e:
        79. # If the view raised an exception, run it through exception
        80. # middleware, and if the exception middleware returns a
        81. # response, use that. Otherwise, reraise the exception.
        82. for middleware_method in self._exception_middleware:
        83. response = middleware_method(request, e)
      ▶ Local vars
      Variable Value
      callback
      <function renderView at 0x5555573e05f0>
      callback_args
      ()
      callback_kwargs
      {}
      debug
      <module 'django.views.debug' from '/usr/lib/python2.4/site-packages/django/views/debug.pyc'>
      e
      <exceptions.MemoryError instance at 0x2aaaaab05050>
      exceptions
      <module 'django.core.exceptions' from '/usr/lib/python2.4/site-packages/django/core/exceptions.pyc'>
      mail_admins
      <function mail_admins at 0x2aaaaac016e0>
      middleware_method
      <bound method AuthenticationMiddleware.process_request of <django.contrib.auth.middleware.AuthenticationMiddleware object at 0x5555572ad790>>
      request
      <ModPythonRequest path:/render/, GET:<MultiValueDict: {'width': ['586'], '_salt': ['1215728882.234'], 'height': ['305']}>, POST:<MultiValueDict: {}>, COOKIES:{'sessionid': 'f15ac2a8ef05241a59a68dc6e41e5249'}, META:{'AUTH_TYPE': None, 'CONTENT_LENGTH': 0L, 'CONTENT_TYPE': None, 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'sessionid=f15ac2a8ef05241a59a68dc6e41e5249', 'HTTP_HOST': '10.100.1.50', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http://10.100.1.50/composer/?', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9) Gecko/2008061004 Firefox/3.0', 'PATH_INFO': '/', 'PATH_TRANSLATED': None, 'QUERY_STRING': 'width=586&height=305&_salt=1215728882.234', 'REMOTE_ADDR': '10.100.55.237', 'REMOTE_HOST': None, 'REMOTE_IDENT': None, 'REMOTE_USER': None, 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': None, 'SERVER_NAME': 'graphite', 'SERVER_PORT': 0, 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'mod_python'}>
      resolver
      <django.core.urlresolvers.RegexURLResolver object at 0x555556f55d50>
      response
      None
      self
      <django.core.handlers.modpython.ModPythonHandler object at 0x5555572ad610>
      settings
      <django.conf.LazySettings object at 0x2aaab748f9d0>
      urlconf
      'web.urls'
      urlresolvers
      <module 'django.core.urlresolvers' from '/usr/lib/python2.4/site-packages/django/core/urlresolvers.pyc'>
    * /usr/local/graphite//webapp/web/render/views.py in renderView
       100. log.rendering('Total rawData rendering time %.6f' % (time() - start))
       101. return response
       102.
       103. # We've got the data, now to render it
       104. if settings.REMOTE_RENDERING: # Rendering on other machines is faster in some situations
       105. image = delegateRendering(requestOptions, graphOptions)
       106. else:
       107. image = doImageRender(requestOptions['graphClass'], data, graphOptions) ...
       108.
       109. response = buildResponse(image)
       110.
       111. if useCache:
       112. cache.set(requestKey, response)
 113.
      ▶ Local vars
      Variable Value
      cachedData
      None
      cachedResponse
      None
      data
      []
      dataKey
      '@20080709_172618:20080710_172618'
      endTime
      datetime.datetime(2008, 7, 10, 17, 26, 18, 700442)
      graphOptions
      {'width': 586, 'height': 305}
      request
      <ModPythonRequest path:/render/, GET:<MultiValueDict: {'width': ['586'], '_salt': ['1215728882.234'], 'height': ['305']}>, POST:<MultiValueDict: {}>, COOKIES:{'sessionid': 'f15ac2a8ef05241a59a68dc6e41e5249'}, META:{'AUTH_TYPE': None, 'CONTENT_LENGTH': 0L, 'CONTENT_TYPE': None, 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'sessionid=f15ac2a8ef05241a59a68dc6e41e5249', 'HTTP_HOST': '10.100.1.50', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http://10.100.1.50/composer/?', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9) Gecko/2008061004 Firefox/3.0', 'PATH_INFO': '/', 'PATH_TRANSLATED': None, 'QUERY_STRING': 'width=586&height=305&_salt=1215728882.234', 'REMOTE_ADDR': '10.100.55.237', 'REMOTE_HOST': None, 'REMOTE_IDENT': None, 'REMOTE_USER': None, 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': None, 'SERVER_NAME': 'graphite', 'SERVER_PORT': 0, 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'mod_python'}>
      requestKey
      'height=305,width=586'
      requestOptions
      {'endTime': datetime.datetime(2008, 7, 10, 17, 26, 18, 700442), 'graphClass': <class web.render.glyph.LineGraph at 0x555557411a70>, 'graphType': 'line', 'startTime': datetime.datetime(2008, 7, 9, 17, 26, 18, 700442), 'targets': []}
      start
      1215728778.7001591
      startTime
      datetime.datetime(2008, 7, 9, 17, 26, 18, 700442)
      targets
      []
      timeInterval
      (datetime.datetime(2008, 7, 9, 17, 26, 18, 700442), datetime.datetime(2008, 7, 10, 17, 26, 18, 700442))
      useCache
      True
    * /usr/local/graphite//webapp/web/render/views.py in doImageRender
       245. imageData = resp.read()
       246. return buildResponse(imageData)
       247.
       248.
       249. def doImageRender(graphClass, graphData, graphOptions):
       250. pngData = StringIO()
       251. t = time()
       252. img = graphClass(graphData, **graphOptions) ...
       253. img.output(pngData)
       254. log.rendering('Rendered PNG in %.6f seconds' % (time() - t))
       255. imageData = pngData.getvalue()
       256. pngData.close()
       257. return imageData
 258.
      ▶ Local vars
      Variable Value
      graphClass
      <class web.render.glyph.LineGraph at 0x555557411a70>
      graphData
      []
      graphOptions
      {'width': 586, 'height': 305}
      pngData
      <cStringIO.StringO object at 0x2aaaaaaff558>
      t
      1215728778.701674
    * /usr/local/graphite//webapp/web/render/glyph.py in __init__
       114. if self.data:
       115. self.drawGraph(**params)
       116. else:
       117. x = self.width / 2
       118. y = self.height / 2
       119. self.setColor('red')
       120. self.setFont(size=math.log(self.width * self.height) )
       121. self.drawText("No Data", x, y, align='center') ...
       122.
       123. def setupCairo(self,outputFormat='png'): #TODO Only PNG supported for now...
       124. #os.chdir( os.path.dirname(__file__) ) #To utilize local font-cache
       125. self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.width, self.height)
       126. self.ctx = cairo.Context(self.surface)
 127.
      ▶ Local vars
      Variable Value
      colorList
      ['blue', 'green', 'red', 'purple', 'brown', 'yellow', 'aqua', 'grey', 'magenta', 'pink', 'gold', 'rose']
      data
      []
      opts
      <cairo.FontOptions object at 0x2aaaaab3a648>
      params
      {'width': 586, 'height': 305}
      self
      <web.render.glyph.LineGraph instance at 0x555557335368>
      x
      293
      y
      152
    * /usr/local/graphite//webapp/web/render/glyph.py in drawText
       174. else:
       175. self.ctx.set_dash([],0)
       176. self.ctx.stroke()
       177.
       178. def drawText(self,text,x,y,font={},color={},align='left',valign='top',border=False,rotate=0):
       179. if font: self.setFont(**font)
       180. if color: self.setColor(**color)
       181. extents = self.getExtents(text) ...
       182. angle = math.radians(rotate)
       183. origMatrix = self.ctx.get_matrix()
       184.
       185. horizontal = {
       186. 'left' : 0,
       187. 'center' : extents['width'] / 2,
      ▶ Local vars
      Variable Value
      align
      'center'
      border
      False
      color
      {}
      font
      {}
      rotate
      0
      self
      <web.render.glyph.LineGraph instance at 0x555557335368>
      text
      'No Data'
      valign
      'top'
      x
      293
      y
      152
    * /usr/local/graphite//webapp/web/render/glyph.py in getExtents
       146. p.update(params)
       147. self.ctx.select_font_face(p['name'], p['italic'], p['bold'])
       148. self.ctx.set_font_size( float(p['size']) )
       149.
       150. def getExtents(self,text=None,fontOptions={}):
       151. if fontOptions:
       152. self.setFont(**fontOptions)
       153. F = self.ctx.font_extents() ...
       154. extents = { 'maxHeight' : F[2], 'maxAscent' : F[0], 'maxDescent' : F[1] }
       155. if text:
       156. T = self.ctx.text_extents(text)
       157. extents['width'] = T[4]
       158. extents['height'] = T[3]
       159. return extents
      ▶ Local vars
      Variable Value
      fontOptions
      {}
      self
      <web.render.glyph.LineGraph instance at 0x555557335368>
      text
      'No Data'

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/graphite//webapp/web/render/views.py" in renderView
  107. image = doImageRender(requestOptions['graphClass'], data, graphOptions)
File "/usr/local/graphite//webapp/web/render/views.py" in doImageRender
  252. img = graphClass(graphData, **graphOptions)
File "/usr/local/graphite//webapp/web/render/glyph.py" in __init__
  121. self.drawText("No Data", x, y, align='center')
File "/usr/local/graphite//webapp/web/render/glyph.py" in drawText
  181. extents = self.getExtents(text)
File "/usr/local/graphite//webapp/web/render/glyph.py" in getExtents
  153. F = self.ctx.font_extents()

  MemoryError at /render/

Revision history for this message
keeps (jfrias-gmail) said :
#2

Woops, sorry the above... here's the traceback from django

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/graphite//webapp/web/render/views.py" in renderView
  107. image = doImageRender(requestOptions['graphClass'], data, graphOptions)
File "/usr/local/graphite//webapp/web/render/views.py" in doImageRender
  252. img = graphClass(graphData, **graphOptions)
File "/usr/local/graphite//webapp/web/render/glyph.py" in __init__
  121. self.drawText("No Data", x, y, align='center')
File "/usr/local/graphite//webapp/web/render/glyph.py" in drawText
  181. extents = self.getExtents(text)
File "/usr/local/graphite//webapp/web/render/glyph.py" in getExtents
  153. F = self.ctx.font_extents()

  MemoryError at /render/

Revision history for this message
keeps (jfrias-gmail) said :
#3

Here are all the versions of the dependencies I'm running

sqlite-devel-3.3.6-2
python-sqlite-1.1.7-1.2.1
python-2.4.5-19
python-memcached-1.40-2.el5
sqlite-3.3.6-2
pycairo-1.2.0-1.1
pycairo-devel-1.2.0-1.1
python-ldap-2.2.0-2.1
memcached-1.2.3-7.el5
mod_python-3.2.8-3.1
pyparsing-1.5.0-1
python-sqlite2-2.3.3-1.el5

Revision history for this message
keeps (jfrias-gmail) said :
#4

Today is my night of copy paste errors...

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response
  77. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/graphite//webapp/web/render/views.py" in renderView
  107. image = doImageRender(requestOptions['graphClass'], data, graphOptions)
File "/usr/local/graphite//webapp/web/render/views.py" in doImageRender
  252. img = graphClass(graphData, **graphOptions)
File "/usr/local/graphite//webapp/web/render/glyph.py" in __init__
  115. self.drawGraph(**params)
File "/usr/local/graphite//webapp/web/render/glyph.py" in drawGraph
  328. self.drawLegend(elements)
File "/usr/local/graphite//webapp/web/render/glyph.py" in drawLegend
  221. extents = self.getExtents(longestName)
File "/usr/local/graphite//webapp/web/render/glyph.py" in getExtents
  153. F = self.ctx.font_extents()

  MemoryError at /render/

Revision history for this message
chrismd (chrismd) said :
#5

I have had this problem before myself a long time ago but unfortunately I cannot remember the exact cause or solution. I do know that it is related to cairo's ability to load fonts, so it may be an issue with libcairo, libfreetype, or libfontconfig. Have you built any of these libraries from source or are they all from distro packages? To see if fontconfig is configured properly, run the "fc-list" command and it should output a bunch of font names immediately. If it hangs for a few seconds before outputting font names then your font cache is not setup, try running "fc-cache" as root then retry the "fc-list", if the problem persists look at the cache settings in your /etc/fonts/fonts.conf

I am pretty sure that is how I resolved the issue for myself.

One thing you might want to try just out of curiousity is to enable the "Graph Only" option in the graph composer's Options menu under Display, this should prevent any font-related cairo calls from being made and so it will probably work.

Revision history for this message
keeps (jfrias-gmail) said :
#6

Yeap, that was it. Turned off fonts and got it working. ( i actually even after it not working built custom rpm's of the latest pycairo and cairo to see if that was the issue) what fonts does it expect?

(i'm installing it in centos 5.x, and being a server, i try to keep the packages to a bare minimum )

Revision history for this message
chrismd (chrismd) said :
#7

It uses cairo's default font (or whatever font you explicitly specify) which on my system looks like Arial. You generally shouldn't have to worry about having the right fonts installed, but rather that fontconfig is working properly. Does the "fc-list" command immediately print a bunch of font names, or does it take a second? I think that the issue for me was that my font cache was not setup properly, and this prevents Cairo from being able to load fonts. You can check your font cache configuration by looking for the <cachedir> entries in your fonts.conf, those directories should be full of files.

Revision history for this message
keeps (jfrias-gmail) said :
#8

[14:16:49] xxxxx root:[~/graphite-0.9.2/examples]
# fc-list
[14:16:59] xxxxx root:[~/graphite-0.9.2/examples]
# fc-cache
[14:17:08] xxxxx root:[~/graphite-0.9.2/examples]
# fc-list
[14:17:12] xxxxx root:[~/graphite-0.9.2/examples]
# grep cachedir /etc/fonts/fonts.conf
 <cachedir>/var/cache/fontconfig</cachedir>
 <cachedir>~/.fontconfig</cachedir>
[14:17:31] xxxxx root:[~/graphite-0.9.2/examples]
# ls /var/cache/fontconfig/
3830d5c3ddfd5cd38a049b759396e72e-x86-64.cache-2
[14:17:44] xxxxx root:[~/graphite-0.9.2/examples]
#

# rpm -qa | grep font
fontconfig-devel-2.4.1-6.el5
fontconfig-2.4.1-6.el5
#

no fonts..

then

Installed: bitmap-fonts.noarch 0:0.3-5.1.1
Complete!
[14:22:36] xxxx root:[~/graphite-0.9.2/examples]
# fc-list
MiscFixed:style=Regular
Console:style=Regular
LucidaTypewriter:style=Sans Bold
MiscFixed:style=SemiCondensed
LucidaTypewriter:style=Sans
MiscFixed:style=Bold
MiscFixed:style=Bold SemiCondensed
Fixed:style=Regular
[14:22:38] xxxx root:[~/graphite-0.9.2/examples]
#

Now fonts... everything works

thanks so much for all the help!