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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:00:39+00:00 2026-06-09T11:00:39+00:00

I’m learning Clojure and I’m wondering why my application is consuming so much memory

  • 0

I’m learning Clojure and I’m wondering why my application is consuming so much
memory and not releasing it once it’s done using those data structures. I
imagine that there is something in Clojure that I don’t know about that is
making the application hold onto some stuff by mistake.

It’s a simple thumbnailing app. It takes images from a directory, resizes
them and puts them into another directory. It uses the javax.imageio and
java.awt.image libraries.

(def thumb "path to thumbnails directory")

(defn get-thumb-filename [thumb-dir filename width]
  (str thumb-dir (fs/name filename) "_" width ".jpg"))

(defn get-thumb-filename-100 [filename]
  (get-thumb-filename thumb filename 100))

(defn small-thumbnail [filename]
  (make-thumbnail filename (get-thumb-filename-100 filename) 100))

(defn make-thumbnail [filename new-filename width]
  (let [img (javax.imageio.ImageIO/read (as-file filename))
        imgtype (java.awt.image.BufferedImage/TYPE_INT_ARGB)
        width (min (.getWidth img) width)
        height (* (/ width (.getWidth img)) (.getHeight img))
        simg (java.awt.image.BufferedImage. width height imgtype)
        g (.createGraphics simg)]
    (.drawImage g img 0 0 width height nil)
    (.dispose g)
    (javax.imageio.ImageIO/write simg "png" (as-file new-filename))))


;; `images` is a list of original filenames
;; Kick it off with...
(pmap small-thumbnail images)

This code is part of a Noir view, meaning that the application doesn’t exit
after the processing of all images is finished.

When I run this code, my computer starts going crazy. The fan gets loud and
the main java process uses over 1GB of memory. When all images are processed,
the CPU usage goes down to < 5% but the memory usage stays the same.

How can I make it release all of this memory that it clearly doesn’t need for
anything?

Thanks!

PS: Please let me know if you need me to fill in any details.

  • 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-09T11:00:41+00:00Added an answer on June 9, 2026 at 11:00 am

    The JVM manages it’s own memory. Once it acquires memory from the operating system, it usually doesn’t give it back. (Or at least I’ve never seen Sun’s JVM do so, there might be some way to force it to…)

    Anyhow, a simple way to see whether or not your program is actually leaking memory using tools that you’ve probably already got installed is to attach a JConsole to your JVM and just monitor the heap usage. Looking at Activity Monitor won’t tell you anything useful.

    http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I need a function that will clean a strings' special characters. I do NOT

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.