Write Louder! (How To Write …?)

Useful Writing Books, Articles, Software

Stream Write Error

without comments

Java socket and memory issues: I am writing a client/server that need to send data and images.?

I am writing a program that needs to track where the server user's mouse is on the screen and send that information back to the client. I also need the client to be able to send an image to the server for display. What is the best way to do this?

Currently I have implemented the image send using ObjectOutputStreams and ObjectInputStreams but I get a "java.lang.OutOfMemoryError: Java heap space" error after sending about 13 images. It points to the input stream as the cause of the error, but if I reinitialize the stream then I get a Stream Corrupted error. Is there a better way to do this or do I have the wrong idea as to what is causing the memory issue?

Also, I am currently running both the send and receive data on the same socket and the Client and Server are each running on their own thread. Is this acceptable or would you suggest another implementation?

Thanks for any help you can provide, I am completely new to threading and sockets.

Two abstract classes shape the architecture of the java.io package: InputStream and OutputStream. These interfaces define the key abstractions for I/O operations. Concrete implementations of InputStream and OutputStream provide access to different types of data sources such as disks and network connections.

The java.io package also provides several filter streams that don't point to a specific data source and are meant to be stacked on top of other streams. These filter streams are at the heart of the java.io architecture. From a performance perspective, the most interesting filter streams are buffered streams.

The leading cause of poor I/O performance is failing to buffer I/O operations. Hard disks are very good at reading and writing sizable chunks of data, but they are much less efficient when working with small blocks of data. To maximize I/O performance, you should batch read and Write operations. This is exactly what buffered streams are designed for.

Key Points

* Reading and writing data in small chunks can be very slow.
* Using BufferedInputStream and BufferedOutputStream to batch requests improves performance.
* In some situations, you can use custom buffering techniques to maximize performance.

Forth visit

http://java.sun.com/docs/books/performance/1st_edition/html/JPIOPerformance.fm.html

hope this will solve you issues
Cheers:)

Minecraft SMP: Connection Issues




Compare............................................................................................


DVD Studio Pro 1.5 [OLD VERSION]


DVD Studio Pro 1.5 [OLD VERSION]


$80.00


Professional DVD Authoring made simple. Includes Mac OS X Version of Corel Photo-Paint 10 and BIAS Peak DV3. Create stunning DVD-Video discs that play on standard DVD Players with DVD Studio Pro, a powerful affordable DVD authoring tool. DVD Studio Pro offers comprehensive support for the DVD-Video standard, including motion and still menus, up to 99 tracks, multiple angles, multiple stories, slid...

Synology DiskStation 4-Bay (Diskless) Network Attached Storage DS411J (White)


Synology DiskStation 4-Bay (Diskless) Network Attached Storage DS411J (White)


$355.00


Synology DiskStation DS411j is designed to provide a cost-effective file storage and backup solution with RAID protection for multi-user home environments. The operating system, Synology DiskStation Manager, delivers rich features for multimedia enjoyments, worry-free backup, Internet sharing, and energy-saving options....

Seagate FreeAgent GoFlex Home 2 TB STAM2000100


Seagate FreeAgent GoFlex Home 2 TB STAM2000100


$143.59


Wireless-ready multi-PC and Mac computer backup and file sharingThe GoFlex Home network storage system supports the external storage needs of every computer in your homeConnects to your WiFi router, allowing you to wirelessly store and access files and back up multiple PC and Mac computers in your home* Store files in a central location on your network--use one drive for all your storage and backu...

D-Link DNS-323 2-Bay Network Attached Storage Enclosure


D-Link DNS-323 2-Bay Network Attached Storage Enclosure


$229.99


SAFELY SHARE DIGITAL FILES LOCALLY AND OVER THE INTERNETThe D-Link DNS-323 2-Bay Network Storage Enclosure, when used with internal SATA drives, enables you to share documents, files, and digital media such as music, photos, and video with everyone on the home or office network. Remotely accessing files through the Internet is also possible with the built-in FTP server. Whether you are allowing ac...

Julie's Gift: Memories of London


Julie's Gift: Memories of London


$12.28


Kevin and Julie travel to London. Kevin loathes sightseeing. Julie is the quintessential tourist. Kevin ends up enjoying the trip but doesn't tell Julie. He secretly writes a book about his fond memories to surprise her and express his love....

.........................................................................................................
Compare............................................................................................


The Stream


The Stream


$59.99


A. Hanriot The Stream - Wall Decal

Stream


Stream


$24.99


Stream - Photographic Print

By the Stream


By the Stream


$14.99


Lucie Bilodeau By the Stream - Art Print

.........................................................................................................


Leave a Reply