Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8352419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:57:23+00:00 2026-06-09T08:57:23+00:00

Tying to setup api with Sinatra App. Each request is 15MB. Every time I

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:57:24+00:00Added an answer on June 9, 2026 at 8:57 am

    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

    1. Memory growth is not inherently a problem unless you actually run out of it. If that isn’t happening, leave it alone.
    2. The mysql2 gem has some known memory issues. That may be applicable to your scenario.
      • https://github.com/brianmario/mysql2/issues/85
      • http://dev.mysql.com/doc/refman/5.0/en/mysql-use-result.html
      • http://numbers.brighterplanet.com/2011/03/15/what-you-should-know-about-mysql2-memory-usage/
    3. Garbage collection doesn’t happen just because a variable or literal goes out of scope. There are conditions which trigger garbage collection, but you shouldn’t monkey around with it or patch your garbage collector unless you are truly memory constrained.
      • http://www.engineyard.com/blog/2011/tuning-the-garbage-collector-with-ruby-1-9-2/
      • http://www.ruby-doc.org/core-1.9.3/GC.html#method-c-stat
    4. Make sure you understand scoping in Sinatra so that you know when objects should be out of scope. However, just because objects are out of scope doesn’t mean they will be garbage-collected, just that they can be.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to setup service to something (api request) everyday at particular time. I dont
I'm trying to setup a CORS enabled API that I can access via JavaScript.
I'm trying to setup a session in Active Record for each WCF request. Here
I'm trying to setup a subdirectory in my Rails 3.2.3 app to service API
Im trying to setup my asp.net mvc page like the following image: The header
Hi all I'm trying to do an API call using a jsonp setup with
I am trying to build a project-page setup that auto populates the project details
I'm trying to write a voip app for Android, using the Android SIP API
Been trying to setup my Facebook app which I want to use for Logins
I am trying to setup django-nonrel on GAE (Google App Engine) - following the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.