I have an app which receives an incoming file (attachment in the form of blob_data), and just passes it on, to another external service/API (while storing the attachment metadata in my app). I don't need to store the blob_data in my app.
class Attachment < ActiveRecord::Base
attr_accessor :blob_data
end
When I call @attachment.save
I presume the blob_data won't be persisted to the DB, because it is an attr_accessor field. But, is there a way to ensure that this blob_data is released from memory immediately? I don't want the blob_data lingering around until the GC catches it at a later time, as it may take up quite a bit of memory, especially if the server receives several requests in the same time period.
Would it be as simple as using @attachment.blob_data = nil
? Will this have any effect on the immediacy of the GC catching it? Is there a better way?