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 7974113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:16:52+00:00 2026-06-04T08:16:52+00:00

So i have an application that creates like 2000 objects. For each object, it

  • 0

So i have an application that creates like 2000 objects.

For each object, it downloads a web page (String of approx. 75kb), creates a DOM document object model of the entire html tree and discards the String (it goes out of scope).

It then extracts some text and links from the DOM, and discards the DOM (by setting it to null).

After about 1000 objects (depending on how much applications I have open, it might be after 50 objects) I get an OutOfMemory exception, and with Process Explorer I can see the memory footprint has been increasing throughout, in logarithmic steps.

I tried inserting a System.gc(); after setting it to null, but memory usage still keeps increasing, but now not with logarithmic steps but with steps of approx 0.5Mb after every processed object. Furthermore, while debugging, whenever I step over System.gc() the footprint increases by this amount, and it stays the same until the instruction pointer is at the same System.gc() again.

[edit]

I ran the profiles on a dump as suggested in an answer, and found that every of those classes still stores a 150kb string (75k chars). This totals 242mb. So the question becomes, how do I keep the substrings without keeping the original string? Apparently the String constructor does this.

  • 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-04T08:16:54+00:00Added an answer on June 4, 2026 at 8:16 am

    One problem could be when extracting substrings is that the long original string is still referenced (good if you want to make many substrings from one original, bad if the original is very long and you only want to use the single substring).

    Try making a dump of the memory to see what objects are retained and where they are referenced. The dump can be obtained with with the -XX:HeapDumpOnOutOfMemoryError when the memory is full. You can also use jmap -dump:format=b,file=heap.bin to get dumps. With this you can get a dump after each time you process a document and then compare the dumps using Eclipse Memory Analyzer Tool (MAT) to see what new objects were created and retained.

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

Sidebar

Related Questions

Today we have a windows application that, using an OCX, creates a web page
I have a web application that creates a graph on another aspx page. Sometimes
I have a .Net application that dynamically creates a small HTML page and pops
I have an application that creates database tables on the fly. I'd like to
I have a php application that sometimes creates two lightboxes on the same page
I have an MFC application that creates a CDialog. I'd like this CDialog to
I have an application that creates a new app domain like this: private static
I have a java application that creates two static objects in a base class,
I have a VBA application that creates an instance of a COM object and
i would like to create an application that needs to have the option to

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.