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

  • Home
  • SEARCH
  • 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 8129049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:08:37+00:00 2026-06-06T08:08:37+00:00

When I load the file into json, pythons memory usage spikes to about 1.8GB

  • 0

When I load the file into json, pythons memory usage spikes to about 1.8GB and I can’t seem to get that memory to be released. I put together a test case that’s very simple:

with open("test_file.json", 'r') as f:
    j = json.load(f)

I’m sorry that I can’t provide a sample json file, my test file has a lot of sensitive information, but for context, I’m dealing with a file in the order of 240MB. After running the above 2 lines I have the previously mentioned 1.8GB of memory in use. If I then do del j memory usage doesn’t drop at all. If I follow that with a gc.collect() it still doesn’t drop. I even tried unloading the json module and running another gc.collect.

I’m trying to run some memory profiling but heapy has been churning 100% CPU for about an hour now and has yet to produce any output.

Does anyone have any ideas? I’ve also tried the above using cjson rather than the packaged json module. cjson used about 30% less memory but otherwise displayed exactly the same issues.

I’m running Python 2.7.2 on Ubuntu server 11.10.

I’m happy to load up any memory profiler and see if it does better then heapy and provide any diagnostics you might think are necessary. I’m hunting around for a large test json file that I can provide for anyone else to give it a go.

  • 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-06T08:08:41+00:00Added an answer on June 6, 2026 at 8:08 am

    I think these two links address some interesting points about this not necessarily being a json issue, but rather just a "large object" issue and how memory works with python vs the operating system

    See Why doesn’t Python release the memory when I delete a large object? for why memory released from python is not necessarily reflected by the operating system:

    If you create a large object and delete it again, Python has probably released the memory, but the memory allocators involved don’t necessarily return the memory to the operating system, so it may look as if the Python process uses a lot more virtual memory than it actually uses.

    About running large object processes in a subprocess to let the OS deal with cleaning up:

    The only really reliable way to ensure that a large but temporary use of memory DOES return all resources to the system when it’s done, is to have that use happen in a subprocess, which does the memory-hungry work then terminates. Under such conditions, the operating system WILL do its job, and gladly recycle all the resources the subprocess may have gobbled up. Fortunately, the multiprocessing module makes this kind of operation (which used to be rather a pain) not too bad in modern versions of Python.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a json file ( ~3Gb ) that I need to load into
How can I load a .java file into a CompilationUnit? For example, lets say
How can I load a CSV file into a System.Data.DataTable , creating the datatable
I'm trying to use Sencha Touch 2 to load a local json file into
I need to get rather complicate JSON data from (large) JSON file into a
What would be the easiest way to load a file containing JSON into a
In my iOS 5.1 application, I'm trying to load a JSON text file into
Struggling to load json from file (myData.json) on URL into an object so I
I have problems trying to load png file into my application. It seems to
I am trying to figure out an eazy way to load CSV file into

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.