• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Download and Multithread  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am coding a download program, I use multithread in this program.
But It has an error ocurred:
It is : OutOfMemory, can not create a new native thread.
I have found solutions:
-increase heap memory size
-reduce max thread using in program.

I have a question :
How the way : JVM control and allocate threads ?

Thanks and best regard.
phuongtg
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, welcome to the ranch!

I'd focus on figuring out what's causing the error before I blindly hand out more memory. Out of memory errors are often caused by recursion that never exits. Any chance that's what you are seeing? What does your stack trace look like?

Or are you trying to store gigantic downloads in memory? It might be better to read a manageable buffer into memory and write it to disk, then read another chunk into the same buffer.

How many threads are you talking about? Do they all run at once or do you create and run and destroy a lot of them?

Show us a small bit of your download code so we can see what's going on.
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One important point is, though, that despite the error message, this really has nothing to do with threads, any more than not being able to fit into your pants is a problem with pants. In both cases, the problem is excessive consumption.

Because this is really not thread-related, I'll move it to Java in General (Intermediate).
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!