Ruby on Rails memory leak when looping through large number of records; find_each doesn’t help

I was able to figure this out myself. There are two places to change. First, disable IdentityMap. In config/application.rb config.active_record.identity_map = false Second, use uncached to wrap up the loop class MemoryTestController < ApplicationController def go ActiveRecord::Base.uncached do Person.find_each do |person| # whatever operation end end end end Now my memory use is under control. … Read more

Recycle ImageView’s Bitmap

In your onDestroy method you could try something like this: ImageView imageView = (ImageView)findViewById(R.id.my_image); Drawable drawable = imageView.getDrawable(); if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; Bitmap bitmap = bitmapDrawable.getBitmap(); bitmap.recycle(); } The cast should work since setImageBitmap is implemented as public void setImageBitmap(Bitmap bm) { setImageDrawable(new BitmapDrawable(mContext.getResources(), bm)); }

Weak event handler model for use with lambdas

‘The’ answer (Read more below if you want to see how I got to this solution) Usage, given a control with a vanilla MouseDown event, and a specific EventHandler<ValueEventArgs> ValueEvent event: // for ‘vanilla’ events SetAnyHandler<Subscriber, MouseEventHandler, MouseEventArgs>( h => (o,e) => h(o,e), //don’t ask me, but it works*. h => control.MouseDown += h, h … Read more

How can I find memory leaks in long-running Perl program?

It may be relevant that Perl never gives memory back to the system by itself: It’s all up to malloc() and all the rules associated with that. Knowing how malloc() allocates memory is important to answering the greater question, and it varies from system to system, but in general most malloc() implementations are optimized for … Read more

Circular References Cause Memory Leak?

Great question! No, Both forms will be (can be) GC’d because the GC does not directly look for references in other references. It only looks for what are called “Root” references … This includes reference variables on the stack, (Variable is on the stack, actual object is of course on the heap), references variables in … Read more

Simple jQuery Ajax call leaks memory in Internet Explorer

Here’s a link to the bug over on jQuery, along with this as a suggested fix for jQuery 1.4.2: — jquery-1.4.2.js 2010-04-08 12:10:20.000000000 -0700 +++ jquery-1.4.2.js.fixed 2010-04-08 12:10:38.000000000 -0700 @@ -5219,7 +5219,7 @@ // Stop memory leaks if ( s.async ) { – xhr = null; + xhr.onreadystatechange = null; xhr.abort = null; xhr = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)