Know about GC?

I have an application where on the basic of users operation the objects(of certian types) are created. I can create them with "new" keyword but don't hav any options to destroy these objects. This is creating a memory leak in my application.
In case of thousand of object my applicaiton may leads to memory exceptions.
what i know abt GC is that it internaly runs..
I even used System.gc() but this even dn't wrked.
i can monitor all objects state with a plugin available in eclipse.
Colud any budy help me to resove this performance issue..
thnx
Puneet Srivastava

i m not retaining reference..You sure?
on user operation i need to write following pseudo
code:
for(1 to n)
myobj = new Object()When the myobj goes out of scope it should be eligible for GC. (assuming you are not also doing something like
loveLivingList.add( myobj );
for each user operation i m creating the reference
but not destroying..You don't need to.
instance r stil in memory when not neededI'm sure I did read a thread where someone was created large amounts of objects before giving the GC time to clean up. But that is a very rare case, it is much more likely you are holding the objects somewhere.
Please make the extra effort to write out words such as "are" and "thanks". The extra keystrokes won't cost much in the way of time, and the enhanced clarity will be appreciated by those communicating on a forum with international readership.

Similar Messages

  • A few days ago i bought the macbook pro in a Providence. In late Summer i will come back to my Country - Ukraine. I would like to know about a tax for my laptop. Can i return tax? Through the TAX FREE or return in airport? What should i do?

    A few days ago i bought the macbook pro in a Providence. In late Summer i will come back to my Country - Ukraine. I would like to know about a tax for my
    laptop. Can i return tax? Through the TAX FREE or return in airport? What should i do?

    You need to talk with the tax authorities in the countries to which you traveled and that of your home country. We are all end-users liek you and not Apple agents.

  • Did you know about Flash Cookies?

    I know about regular cookies, and delete them... but had no idea there was such a thing as a Flash Cookie
    Read about 1/2 way down here http://windowssecrets.com/comp/100805

    Rod,
    Since you're a confessed geek with some actual coding chops, I'm sure you'll understand the hair I'm about to split here. Hang on a moment while I grab my axe...
    Even with your page jumps, the cookie isn't doing anything. It's just a text file named after a snack. What's causing your page to jump, browsers to redirect, and the moon to shift its gravitational field three degrees to the north is the code in the web page that's being loaded. True, it may look in the text file to see what IP address to report to, but the connection, handshaking, transfer of data and powering up of lasers are all on your web page (or the server side code being executed on its behalf). The cookie is little more than a poorly dressed informant hanging out on the street corner waiting to pass along tidbits of information when the right person asks. Doesn't exactly make it a savory character (name notwithstanding), but it's a harmless one nonetheless. If it's evil you seek, you'll find it in the web site, not the cookie. And that's why I never understood the religious fervor against cookies.
    Now, if you want a truly dangerous leave behind, at least on Windows, ActiveX controls are your guys. They're really just glorified COM objects, and thus have complete access to the entire Windows API. Give me permission to install an ActiveX control on your machine and I can rewrite your file system, start and stop services, reboot your computer, or just turn the screen a hyperintelligent shade of the color blue because it amuses me. Anything that can be done in Windows programming is essentially available to the ActiveX control.
    Of course, browsers got hip to this years ago, and now the default security settings for ActiveX are to not install automatically, or at least to query the user first. Or, as it's configured on my machine, feel free to install if you can make it past this shotgun pointed at your head. Maybe that's why there's not as much of a flap about ActiveX as there is about cookies. Because they're truly dangerous, the browser community took it seriously.and now only someone with a death wish allows a web page to install an ActiveX component.
    And overall, this is kinda my point. The much maligned cookie gets a bad rap while in truth it's the web page staring you right in the face that's preparing to rob, rape and pillage. But then, misdirection has always been a classic tactic in warfare.

  • Did you know about "Arbitration and Mediation" FAQ?

    I have just made a discovery that many of you frustrated Verizon customers will be very interested in knowing about. Did you know that you can type in legal action in the search verizon.com box and you will find a category called "Arbitration & Mediation" FAQ? For those of you, like myself who have been dealing with months and months of issues with Verizon and you are getting nowhere, you might check this out. It is very interesting.This may have saved me hours and hours of time and some over the top emotion that our situation has caused.

    Proper names are known. But product names will not be - nor will acronyms.

  • I need to upgrade memory slots on my Mac mid 2010 up to 4 GB module which is currently 2GB with two different 1GB memory  slots.Is it compatible and would like to know about the cost?

    I need to upgrade memory slots on my Mac mid 2010 up to 4 GB module which is currently 2GB with two different 1GB memory  slots.Is it compatible and would like to know about the cost?

    this sub forum is about running windows on macs maybe you should try
    https://discussions.apple.com/community/notebooks/macbook

  • I am getting messages that I can't download and read .pdf files since I have the wrong Adobe reader. I know about their security disasters of course, but I downloaded the latest version of Adobe Reader from the Adobe web site and I have other ,pdf file re

    I am getting messages that I can't download and read .pdf files since I have the wrong Adobe reader. I know about their security disasters of course, but I downloaded the latest version of Adobe Reader from the Adobe web site and I have other ,pdf file readers as well, and for some reason they won't work either. I have 5 computers running top end processors and RAM. By this I mean I have one, this one which I am using that has an AMD Phenom Black 3.2 Quad-core with 8 GBs of Corsair top DDR2 RAM, my other two AMD have either an Athlon II triple core with 4 GBs of DDR2 Corsair RAM, one with the Phenom X4 965 3.4 GHz Quad-core with 8 GBs of their best DDR2 RAM, and two Intels with the i7 920 Processors using the triple channel 1366 socket processors and one with 8 GBs of low latency DDR3 RAM and the other with 4 GBs of the same RAM. I am getting the message on this one, which has a fresh install of XP Pro X64 operating system, as do the other 4 as well. I have run Avast Business Pro Anti-virus on this one, which I am getting the message on with a single result which I deleted, and also both Spybot Search and Destroy, which came back clean as well as Malwarebytes Antimalware, which got a lot of tracing cookies now removed, and SuperAntiSpware which also found a few cookies also now deleted. Can you tell me what I need to do to get these files to show as .pdf files rather than as a clean blank page. One other issue is that I wish to know how to turn off my downloads so they are saved and Mozilla will give me the option of returning them instead of me losing them all together as it does now. Thanks for your assistance. If there is another Adobe reader I should download and install, could you provide me with the link to it? I appreciate your assistance here
    == When I download and try to read a .pdf file and when I am asked to turn off all Firefox files and if I do, I lose them since I need to know how to save them without rebooting my computer.

    Brilliant! Problem solved! Thanks so much.

  • In app purchase is not working in testing environment in sandbox for the past 5 days. Please anyone know about this issue.

    in app purchase is not working in testing environment in sandbox for the past 5 days. Please anyone know about this issue.
    What i did
      1 . Added three products more to the existing in-app
      2 . Tested with sanbox
    i am getting the error "cannot connect to itunes store" with error code "0" when trying to purchase product in sandbox.
    Is sandbox is down?Please help guys..

    Apple's sandbox has been down practically all month. You can check the status here:
    http://sandbox.itunes.apple.com

  • Firefox 4 Beta crashes everytime I open it. Then I'm forced to close the program and it won't let me restart it since it says it's already running. Which isn't true. I'm done trying it. Do you guys know about this problem?

    Everytime I start Firefox 4 beta it crashes. I usually can visit one site on the web (doesn't matter what site) and then it locks up. The only thing that works on the browser then is the close button. After clicking the close button I'll try to restart the browser and I'll get an error message saying it can't open Firefox because it's already open. Which is a bunch of BS. The only I can get Firefox started again is to restart my computer. This is so frustrating that I've given up trying. Hopefully you guys know about this bug and can do something about it. I wasn't trying to post a question here I just wanted to make sure you guys heard about this problem.

    yeah it is the gayest thing that happens :S what i do is turn off the internet, then open it, then turn on internet, then use it. :S OR make your homepage a tab.

  • My iphone was stolen and we actually recovered it!  Is there a way I can tell what the thief might have looked at in the interim? I know about hitting the home button twice to see recently used apps, but what if they then swiped to close them?  TIA

    My iphone was stolen and we actually recovered it using the find my iphone app!  Is there a way I can tell what the thief might have looked at in the interim? I know about hitting the home button twice to see recently used apps, but what if they then swiped to close them?  i just want to know if this <bleep> was looking through my private info.  TIA

    Sorry marcia,
    There is no way to tell what activity went on on your device when it was out of your hands.
    Sorry,
    GB

  • How do we let Apple know about the Apple ID Issue?

    Hi, there seems to be an issue (Apple's end)  with signing in to the Itunes store and the Mac App store. How do we let them know about the issue? Their service status shows all green lights so it seems they are not aware of the problem.... I don't know about you but I'm getting really frustrated.. !! PS It seems that my warranty has expired so I don't have direct access to their support ?! HEEEEEEEEELP! THAAAAAANX!!!!!
    Milan, Italy, March 11

    Hi valelorandi,
    I understand that you are seeing an issue with your connection to the iTunes Store and Mac App Store. I have an article for you that will help you address this issue, and it can be found below:
    Can't connect to the iTunes Store - Apple Support
    https://support.apple.com/en-us/HT201400
    Thanks for using the Apple Support Communities. Have a good one!
    -Braden

  • Hi, Dear. I purcahse my iphone 4S on of the guy, my problem is when i update any app from App store and i click update there is an e-mail address is coming which i doesnt know about the password, how can i revome the e-mail address for update our apps.

    Hi, Dear. I purcahse my iphone 4S on of the guy, my problem is when i update any app from App store and i click update there is an e-mail address is coming which i doesnt know about the password, how can i revome the e-mail address for update our apps.

    Yes. Delete the Apps that were not Purchased using Your Apple ID.
    But a Restore as New is the way to go.

  • I just got my replacement phone from Warranty. The phone was on for just 2 hours and it crashed. I was told that motorola knows about this "possible" issue. I got a new sim, hard reset, If it can be done I did it. They are now sending me the same phone ag

    I just got my replacement phone from Warranty. The phone was on for just 2 hours and it crashed. I was told that motorola knows about this "possible" issue. I got a new sim, hard reset, If it can be done I did it. They are now sending me the same phone again. Number 3. I would hope this one doesn't crash but I rather have a different phone so I can enjoy using my account. The phone's most recent error was today. " Unfortunately, the process com.motorola.widget.circlewidget3d" has stopped. At least the error message works and it's polite. I told tech this and they could not answer my question or help me other then "let's do a hard reset" My warranty replacement is coming on Monday. Let's hope this one works. Anyone else havinbg the same problem. it says "such and such as stop working" on all sorts of stuff! Help! I want my iPhone Back!

    I just did a google search on this issue. OMG, I got a ton of videos on this or similar issues. Each one says in some way to clear the cache, reset the data, etc. Why in the world would this continue to happen and they not do a fix that resloves this without having to lose or stop what your doing. This is a very long and constant issue it seems with Android phones as there must have been pages and pages of what I now call "Unfortunately"  So I am going to pray that Verizon helps me  out and gets me away from this issue and helps me go back to iPhone or try the Samsung.

  • Everything you need to know about Foxtel Go

    Foxtel on T-Box customers can self register Foxtel Go on 2 devices per Foxtel on T-Box subscription. You are able to view content on 1 of the 2 registered devices. The T-Box device will automatically be registered on your behalf and cannot be deregistered. You can change the device they have registered once per calendar month.
    To change a registered device you must log into the Foxtel Go app. As a Foxtel from Telstra customer please use your Foxtel My account details. As a Foxtel on T-Box customer please log in with your primary (i.e. the first username created and linked to your account) BigPond username and password.
    Once in the app go to the settings icon and choose 'manage my devices'. Within this section of the app you will be able to select de-register for the device you wish to change. To register, download the Foxtel Go app and log in. You will be prompted to register the device.
    Remember you can only change one device once per calendar month. If you are still able to make a change, you will be advised of the number of device registrations left this month.
    If you recently registered your T-Box, you should have access to Foxtel Go within 1 hour. If you are experiencing errors please try closing the Foxtel Go App and logging in again. If you are still unable to access any content please contact us via Telstra 24x7 or Telstra Technical Support on 13 22 00
    If you swap your Foxtel on T-Box service to a new device, your Foxtel Go service is not affected as it is associated to your BigPond username and password, and not the T-Box device.
    When trying to make a second device change within a month the de-register' button will be greyed out, preventing the change.
    Current channel rights only allow Foxtel Go to be registered on 3 devices per Foxtel Account. For Foxtel on T-Box customers, the T-Box counts as your 3rd device.
    The parental control function is specific to Foxtel Go and managed in the app via the settings icon. To access parental control:
    Go to the settings' icon in the app (top right)
    Access parental controls'
    Choose which classifications you'd like to restrict
    All R-rated content is automatically blocked, but you can personalise your restrictions for other ratings. To do this go to Settings in the Foxtel Go app, turn on Parental Controls and restrict the classifications you would like to block. If this is the first time you do this you'll be prompted to set a 4 digit PIN specifically for Foxtel Go. You can use this PIN to change your parental controls in the future. This PIN is only applicable to the Foxtel Go app. For Foxtel from Telstra customers, the PIN is not the same as you use on your IQ or Set Top Box, and you will be required to setup a new PIN to restrict content on Foxtel Go. For Foxtel on T-Box customers, the PIN is not the same as you use on your T-Box, and you will be required to setup a new PIN to restrict content on Foxtel Go.
    Foxtel Go content is unmetered with Telstra BigPond Home Broadband services. With other internet service providers this will be offset against your data plan.
    If you use Foxtel Go on your device with any 3G/4G telecommunications service provider, including Telstra, usage isn't unmetered and you will incur data charges when using Foxtel Go. The below list provides an indicationof the data you will use per device on the various app settings, based on watching an hour of TV. To view your settings go to the 'settings' icon in the Foxtel Go App, turn on 'video settings' and choose your preferred quality:
    3G Phone/Tablet Best: 320 MB per hour / Low: 170 MB per hour
    Wi-Fi Phone Best: 420 MB per hour / Low: 320 MB per hour
    Wi-Fi Tablet Best: 720 MB per hour / Low: 320 MB per hour
    Wi-Fi PC/Mac Best: 1310 MB per hour / Low: 470 MB per hour
    The size of each episode or Movie on Catch up TV can be found on the Synopsis tab.
    You can use Foxtel Go at a Wi-Fi location or a personal hotspot when you are in Australia provided you have an internet connection. Some locations offer Wi-Fi hotspots where you can log onto the internet for free. e.g. McDonalds, Starbucks, etc. Any data charges incurred are charged to the business and not to you. When connected to Wi-Fi, you'll see a Wi-Fi symbol on your device.
    Foxtel from Telstra customers with a Foxtel iQ or iQHD set top box can Remote Record and send a channel change to their set top box. Unfortunately this functionality is not available to Foxtel on T-Box customers.
    You can pause and rewind the last 30 minutes of Live TV, even if you've just changed to that channel. Due to device restrictions users of Samsung Android devices are unable to use this feature.
    Foxtel Go is a streaming video service. Streaming means that images and sound are delivered live to your device to view when you press Play, rather than being downloaded to your device to view at a later time.
    Games you'd normally see on Foxtel from Telstra or Foxtel on T-Box on FOX SPORTS 3 are broadcast on Foxtel Go on the Footy Play Plus channel
    There are no Catch Up of AFL games or magazine shows on Foxtel Go due to content restrictions.
    The key symbol indicates that a channel isn't part of your package. You need to upgrade your Foxtel from Telstra or Foxtel on T-Box package to watch it. Your package can not be updated through the Foxtel Go app. For Foxtel on T-Box customers you can update your packages in the T-Box App, at www.telstra.com/tboxsetup, via 13 2200 or in store. For Foxtel from Telstra customers you can update your packages through the store or via 13 1999. The lock symbol indicates that, as part of your parental control setting, you've locked this classification of content, and can't watch it. If you want to change the settings then the primary (i.e. the first username created and linked to your account) account holder can change these by:
    Go to the settings' icon in the app (top right)
    Access parental controls'
    Choose which classifications you'd like to restrict
    No other username or password can change the parental control settings.
    We may be required to block out specific programming from time to time, e.g. if a channel doesn't have the legal right to broadcast the programme over the internet. However, all live channels are the same as channels you watch through Foxtel from Telstra or Foxtel on T-Box.
    The vast majority of the Foxtel on T-Box content is available via Foxtel Go. There are some minor exceptions. MTV Music and MTV Dance channels are not available. FOOTY PLAY and FOOTY PLAY+ (overflow) channels are not available on PC and Mac only.
    Access to Foxtel Go is included in your Foxtel on T-Box and Foxtel from Telstra subscription. However, you will incur data charges when accessing the service on a 3G/4G network.

    Re: Everything you need to know about Foxtel Go
    Iam book in to have foxtel install on 2nd of March was offered Thursday the 28 my appointment has been cancelled so can be home Thursday I put a complaint in as was told it was 1hour for change over from T Box but no one has got back to me

  • Things you need to know about 6280

    Hi everybody, I used to have a 6680 and I say this with regret. Why? I gave it to my girlfriend as a gift. Now that was a good sturdy functional phone. Now I bought a 6280 from Vodafone. I wanted a N70 but the Vodafone representative recommended this one. I chose to go with the 6280 because the N70 looked a little bit too fragile. She also said there are no significant differences. Well, she couldn’t be more wrong. Let me tell you why. The first thing I should mention is that 6280 is not a symbian phone! This, for who knows what it means, it is a lot. I wasn’t aware. You cannot switch between applications for one. So now since I bought it, I gave it a go, see what it is all about. Nice graphics, big screen, no problems (I read here somebody had some). The first annoying thing that hit me is the back light. Goes out in an instant. Or 10 seconds they say. Depends on how you measure time. The problem is you cannot adjust that. Neither the contrast. Nor the luminosity. Some people find these features useful. Nokia seems doesn’t. Some people said on this forum that the sliding front does not have a good grip. Mine seem to do. Navigating through folders is somewhat frustrating but this is subjective. Another thing you should know is that you cannot set the memory card as the default storage space and the phone memory is small. Just about 5MB free with … nothing on it. But I guess you can get around that and be happy with what you have. Now for the real problems. One big issue for me was synchronizing with Outlook. I got it working in the first try. No problems there. But when checking the contact list on the phone … well, disappointment. The 6280 does not record company name, job title and birthday. This is a huge problem for somebody well organized like me. Birthdates are saved in calendar but they do not show up in the contact details. Try finding a birthday through the entire calendar! Second thing that got me down is that the contact phones have no area codes. This you might say “well, it’s ok”. Not if you modify something and then you get your contact updated in Outlook with no area codes. Again BIG problem. My second frustration was with the email accounts. It was hell to figure out how to configure and then I realized. If you have multiple email accounts … you should get another phone. 6680 is good. I assume any symbian enabled phone will do. Not this one. You cannot have all the emails grouped or in separate folders at least as it is on s60 phones. No. here you have to go to “Menu – Settings – Configuration – Personal Config Settings – select other email account and activate it”. Then you go back and go into the email folder. Good job Nokia! I think they could have found a worst sequence to do it. Also, get this, I assume (99% I know) that the emails get stored in the phone memory. You have no way of moving to memory card and no way of reading office or pdf files. Note that on symbian there are applications to do it. As for the battery, I don’t know yet. It did not last one day anyway but I gave it a good run and I know it will improve after several recharges. The good things I know about this phone is that the video has a good quality. I cannot say for pictures because I do have a professional digital SLR camera and I cannot compare without being mean. It is still a phone. The radio is average. Good enough I say. Small note to end this. The phone should have predictive text input. Should, because it is not in the menu. A problem that a firmware update should resolve. I don’t know to what version since I might have the last one. It is: v 03.60 10-02-06. I would buy another model. If you are like me, pay attention to all I had to say. Cheers!

    Good posts a lot of information I needed or to know, or more so wish I'd known prior to purchasing the 6280. Came across this post while trying to find resolutions to a number of the 'problems' with this model that you've listed, or for accuracy's sake functional and features missing from this phone or poorly develop, in comparison to other models.
    Fact: One 'bug' that hasn't been raised in these posts is the management of a contact thumbnail's through PC Suite does work. Adding a thumbanil on the PC doesn't appear on the phone, and adding a thumbnail on the phone doesn't appear on the PC.
    Oppinion: The lack of management/handling of Company name & Birthday were the killer for me!
    Fact: Also I've only had the phone about 2 days now and I've had it just stop and mysteriously restart on me about 4 times. Admittly I've been using it a lot but not doing anything out of the ordinary to expect that.
    Oppinion: On the plus side the screens resolution great, and the photos very good for a phone. Neat little cropping tool, but nothing to rotate. Although the camera doesn't have a protector the case can be replace fixing and scratches! The phone is generally pretty responsive, boots and shuts down very quickly too.
    Oppinion: I'm probably being over critical here but the video call's camera at half arms length barely shows your whole face, at full arms length it's 'closer' to what you'd see on a passport. Although at this distance viewing the person your calling is more difficult. The phone has a good digital zoom in-out feature during a video call. But given the small portion of you shown under normal circumstances I don't imagine this would get used often. Admittly it was entertaining to keep the phone where it was and zoom in on my eye, but it's entertainment value will wear off (or maybe i could call me iridologist).

  • What every developer should know about character encoding

    This was originally posted (with better formatting) at Moderator edit: link removed/what-every-developer-should-know-about-character-encoding.html. I'm posting because lots of people trip over this.
    If you write code that touches a text file, you probably need this.
    Lets start off with two key items
    1.Unicode does not solve this issue for us (yet).
    2.Every text file is encoded. There is no such thing as an unencoded file or a "general" encoding.
    And lets add a codacil to this – most Americans can get by without having to take this in to account – most of the time. Because the characters for the first 127 bytes in the vast majority of encoding schemes map to the same set of characters (more accurately called glyphs). And because we only use A-Z without any other characters, accents, etc. – we're good to go. But the second you use those same assumptions in an HTML or XML file that has characters outside the first 127 – then the trouble starts.
    The computer industry started with diskspace and memory at a premium. Anyone who suggested using 2 bytes for each character instead of one would have been laughed at. In fact we're lucky that the byte worked best as 8 bits or we might have had fewer than 256 bits for each character. There of course were numerous charactersets (or codepages) developed early on. But we ended up with most everyone using a standard set of codepages where the first 127 bytes were identical on all and the second were unique to each set. There were sets for America/Western Europe, Central Europe, Russia, etc.
    And then for Asia, because 256 characters were not enough, some of the range 128 – 255 had what was called DBCS (double byte character sets). For each value of a first byte (in these higher ranges), the second byte then identified one of 256 characters. This gave a total of 128 * 256 additional characters. It was a hack, but it kept memory use to a minimum. Chinese, Japanese, and Korean each have their own DBCS codepage.
    And for awhile this worked well. Operating systems, applications, etc. mostly were set to use a specified code page. But then the internet came along. A website in America using an XML file from Greece to display data to a user browsing in Russia, where each is entering data based on their country – that broke the paradigm.
    Fast forward to today. The two file formats where we can explain this the best, and where everyone trips over it, is HTML and XML. Every HTML and XML file can optionally have the character encoding set in it's header metadata. If it's not set, then most programs assume it is UTF-8, but that is not a standard and not universally followed. If the encoding is not specified and the program reading the file guess wrong – the file will be misread.
    Point 1 – Never treat specifying the encoding as optional when writing a file. Always write it to the file. Always. Even if you are willing to swear that the file will never have characters out of the range 1 – 127.
    Now lets' look at UTF-8 because as the standard and the way it works, it gets people into a lot of trouble. UTF-8 was popular for two reasons. First it matched the standard codepages for the first 127 characters and so most existing HTML and XML would match it. Second, it was designed to use as few bytes as possible which mattered a lot back when it was designed and many people were still using dial-up modems.
    UTF-8 borrowed from the DBCS designs from the Asian codepages. The first 128 bytes are all single byte representations of characters. Then for the next most common set, it uses a block in the second 128 bytes to be a double byte sequence giving us more characters. But wait, there's more. For the less common there's a first byte which leads to a sersies of second bytes. Those then each lead to a third byte and those three bytes define the character. This goes up to 6 byte sequences. Using the MBCS (multi-byte character set) you can write the equivilent of every unicode character. And assuming what you are writing is not a list of seldom used Chinese characters, do it in fewer bytes.
    But here is what everyone trips over – they have an HTML or XML file, it works fine, and they open it up in a text editor. They then add a character that in their text editor, using the codepage for their region, insert a character like ß and save the file. Of course it must be correct – their text editor shows it correctly. But feed it to any program that reads according to the encoding and that is now the first character fo a 2 byte sequence. You either get a different character or if the second byte is not a legal value for that first byte – an error.
    Point 2 – Always create HTML and XML in a program that writes it out correctly using the encode. If you must create with a text editor, then view the final file in a browser.
    Now, what about when the code you are writing will read or write a file? We are not talking binary/data files where you write it out in your own format, but files that are considered text files. Java, .NET, etc all have character encoders. The purpose of these encoders is to translate between a sequence of bytes (the file) and the characters they represent. Lets take what is actually a very difficlut example – your source code, be it C#, Java, etc. These are still by and large "plain old text files" with no encoding hints. So how do programs handle them? Many assume they use the local code page. Many others assume that all characters will be in the range 0 – 127 and will choke on anything else.
    Here's a key point about these text files – every program is still using an encoding. It may not be setting it in code, but by definition an encoding is being used.
    Point 3 – Always set the encoding when you read and write text files. Not just for HTML & XML, but even for files like source code. It's fine if you set it to use the default codepage, but set the encoding.
    Point 4 – Use the most complete encoder possible. You can write your own XML as a text file encoded for UTF-8. But if you write it using an XML encoder, then it will include the encoding in the meta data and you can't get it wrong. (it also adds the endian preamble to the file.)
    Ok, you're reading & writing files correctly but what about inside your code. What there? This is where it's easy – unicode. That's what those encoders created in the Java & .NET runtime are designed to do. You read in and get unicode. You write unicode and get an encoded file. That's why the char type is 16 bits and is a unique core type that is for characters. This you probably have right because languages today don't give you much choice in the matter.
    Point 5 – (For developers on languages that have been around awhile) – Always use unicode internally. In C++ this is called wide chars (or something similar). Don't get clever to save a couple of bytes, memory is cheap and you have more important things to do.
    Wrapping it up
    I think there are two key items to keep in mind here. First, make sure you are taking the encoding in to account on text files. Second, this is actually all very easy and straightforward. People rarely screw up how to use an encoding, it's when they ignore the issue that they get in to trouble.
    Edited by: Darryl Burke -- link removed

    DavidThi808 wrote:
    This was originally posted (with better formatting) at Moderator edit: link removed/what-every-developer-should-know-about-character-encoding.html. I'm posting because lots of people trip over this.
    If you write code that touches a text file, you probably need this.
    Lets start off with two key items
    1.Unicode does not solve this issue for us (yet).
    2.Every text file is encoded. There is no such thing as an unencoded file or a "general" encoding.
    And lets add a codacil to this – most Americans can get by without having to take this in to account – most of the time. Because the characters for the first 127 bytes in the vast majority of encoding schemes map to the same set of characters (more accurately called glyphs). And because we only use A-Z without any other characters, accents, etc. – we're good to go. But the second you use those same assumptions in an HTML or XML file that has characters outside the first 127 – then the trouble starts. Pretty sure most Americans do not use character sets that only have a range of 0-127. I don't think I have every used a desktop OS that did. I might have used some big iron boxes before that but at that time I wasn't even aware that character sets existed.
    They might only use that range but that is a different issue, especially since that range is exactly the same as the UTF8 character set anyways.
    >
    The computer industry started with diskspace and memory at a premium. Anyone who suggested using 2 bytes for each character instead of one would have been laughed at. In fact we're lucky that the byte worked best as 8 bits or we might have had fewer than 256 bits for each character. There of course were numerous charactersets (or codepages) developed early on. But we ended up with most everyone using a standard set of codepages where the first 127 bytes were identical on all and the second were unique to each set. There were sets for America/Western Europe, Central Europe, Russia, etc.
    And then for Asia, because 256 characters were not enough, some of the range 128 – 255 had what was called DBCS (double byte character sets). For each value of a first byte (in these higher ranges), the second byte then identified one of 256 characters. This gave a total of 128 * 256 additional characters. It was a hack, but it kept memory use to a minimum. Chinese, Japanese, and Korean each have their own DBCS codepage.
    And for awhile this worked well. Operating systems, applications, etc. mostly were set to use a specified code page. But then the internet came along. A website in America using an XML file from Greece to display data to a user browsing in Russia, where each is entering data based on their country – that broke the paradigm.
    The above is only true for small volume sets. If I am targeting a processing rate of 2000 txns/sec with a requirement to hold data active for seven years then a column with a size of 8 bytes is significantly different than one with 16 bytes.
    Fast forward to today. The two file formats where we can explain this the best, and where everyone trips over it, is HTML and XML. Every HTML and XML file can optionally have the character encoding set in it's header metadata. If it's not set, then most programs assume it is UTF-8, but that is not a standard and not universally followed. If the encoding is not specified and the program reading the file guess wrong – the file will be misread.
    The above is out of place. It would be best to address this as part of Point 1.
    Point 1 – Never treat specifying the encoding as optional when writing a file. Always write it to the file. Always. Even if you are willing to swear that the file will never have characters out of the range 1 – 127.
    Now lets' look at UTF-8 because as the standard and the way it works, it gets people into a lot of trouble. UTF-8 was popular for two reasons. First it matched the standard codepages for the first 127 characters and so most existing HTML and XML would match it. Second, it was designed to use as few bytes as possible which mattered a lot back when it was designed and many people were still using dial-up modems.
    UTF-8 borrowed from the DBCS designs from the Asian codepages. The first 128 bytes are all single byte representations of characters. Then for the next most common set, it uses a block in the second 128 bytes to be a double byte sequence giving us more characters. But wait, there's more. For the less common there's a first byte which leads to a sersies of second bytes. Those then each lead to a third byte and those three bytes define the character. This goes up to 6 byte sequences. Using the MBCS (multi-byte character set) you can write the equivilent of every unicode character. And assuming what you are writing is not a list of seldom used Chinese characters, do it in fewer bytes.
    The first part of that paragraph is odd. The first 128 characters of unicode, all unicode, is based on ASCII. The representational format of UTF8 is required to implement unicode, thus it must represent those characters. It uses the idiom supported by variable width encodings to do that.
    But here is what everyone trips over – they have an HTML or XML file, it works fine, and they open it up in a text editor. They then add a character that in their text editor, using the codepage for their region, insert a character like ß and save the file. Of course it must be correct – their text editor shows it correctly. But feed it to any program that reads according to the encoding and that is now the first character fo a 2 byte sequence. You either get a different character or if the second byte is not a legal value for that first byte – an error.
    Not sure what you are saying here. If a file is supposed to be in one encoding and you insert invalid characters into it then it invalid. End of story. It has nothing to do with html/xml.
    Point 2 – Always create HTML and XML in a program that writes it out correctly using the encode. If you must create with a text editor, then view the final file in a browser.
    The browser still needs to support the encoding.
    Now, what about when the code you are writing will read or write a file? We are not talking binary/data files where you write it out in your own format, but files that are considered text files. Java, .NET, etc all have character encoders. The purpose of these encoders is to translate between a sequence of bytes (the file) and the characters they represent. Lets take what is actually a very difficlut example – your source code, be it C#, Java, etc. These are still by and large "plain old text files" with no encoding hints. So how do programs handle them? Many assume they use the local code page. Many others assume that all characters will be in the range 0 – 127 and will choke on anything else.
    I know java files have a default encoding - the specification defines it. And I am certain C# does as well.
    Point 3 – Always set the encoding when you read and write text files. Not just for HTML & XML, but even for files like source code. It's fine if you set it to use the default codepage, but set the encoding.
    It is important to define it. Whether you set it is another matter.
    Point 4 – Use the most complete encoder possible. You can write your own XML as a text file encoded for UTF-8. But if you write it using an XML encoder, then it will include the encoding in the meta data and you can't get it wrong. (it also adds the endian preamble to the file.)
    Ok, you're reading & writing files correctly but what about inside your code. What there? This is where it's easy – unicode. That's what those encoders created in the Java & .NET runtime are designed to do. You read in and get unicode. You write unicode and get an encoded file. That's why the char type is 16 bits and is a unique core type that is for characters. This you probably have right because languages today don't give you much choice in the matter.
    Unicode character escapes are replaced prior to actual code compilation. Thus it is possible to create strings in java with escaped unicode characters which will fail to compile.
    Point 5 – (For developers on languages that have been around awhile) – Always use unicode internally. In C++ this is called wide chars (or something similar). Don't get clever to save a couple of bytes, memory is cheap and you have more important things to do.
    No. A developer should understand the problem domain represented by the requirements and the business and create solutions that appropriate to that. Thus there is absolutely no point for someone that is creating an inventory system for a stand alone store to craft a solution that supports multiple languages.
    And another example is with high volume systems moving/storing bytes is relevant. As such one must carefully consider each text element as to whether it is customer consumable or internally consumable. Saving bytes in such cases will impact the total load of the system. In such systems incremental savings impact operating costs and marketing advantage with speed.

  • I want to know about time machine if i can use the hard drive that i use for time machine back up as a normal hard drive too or if it's only for time machine

    I want to know about time machine if i can use the hard drive that i use for time machine back up as a normal hard drive too or if it's only for time machine
    and if it yes i want to know if i have 1TB hard disk to use the 500gb for time machine and the other 500gb for normal use

    thank you very much because i am considering to buy the porsche design hard disk 1TB and i want to have it for normal use and for time machine is a pitty to give 1TB for back up only again thanks and i know seperate the back and the working jobs are better but the i have to have 2 hardisks and i want only 1

Maybe you are looking for

  • Controlling my stereo with my Ipad

    I have just purchased an Ipad (16 GB, no 3G) and would like to use it to control the music at home. I have a NAS server to hold all my music, my photos etc. and an airport express (borrowed), but my laptop is rather old/slow, so would rather not go t

  • My screenshots have stopped going to my clipboard. How can I get my screenshots back into the clipboard?

    I use Command (⌘)-Shift-4 to grab screenshots of diagrams to make flashcards with on a daily basis. But now my screenshots have stopped going to my clipboard - and they don't paste into my flashcards. Dropbox popped up and asked me if I wanted to use

  • Function and number of rows

    Hi ..is it possible to write a function that will take a table name and a where clause as parameters and return the number of rows in the table that satisfy the where clause...? thanks W

  • Sequential Execution of database statements in ABAP

    Hi,     I want to update some rows of table(userdefined) purchase order and my requirement is to change the status of that table after i clicked on that particular record.     Can we do that eventhandling type of things in ABAP. My table structure is

  • Workflow integration with IHS ?

    Hi Experts, We have a specific requirement to create the sap sap workflows from the IHS risk analysis. The deviation in the risk should trigger the workflow as a followup action.There is no standard object in ehs for this,as per my understanding. Doe