Tying to setup api with Sinatra App.
Each request is 15MB. Every time I refresh the page it adds 15MB of memory. How can I clear information after each request?
require 'rubygems'
require 'sinatra'
require 'active_record'
require 'mysql2'
require 'json'
client = Mysql2::Client.new(adapter: 'mysql2', host: '127.0.0.1', database: 'dev_app', username: 'root', password: 'root')
get '/people' do
q = "select name, age from people;"
people = client.query(q, :as => :json).map{|one| {one['name'] => one['age'].to_i}}
return people.to_json
people = nil
end
Profile, profile, profile
You have not identified what is actually consuming memory in your application. Therefore, your issue is undefined, and any “solutions” amount to floundering around in search of a potential answer.
Potential Answers