• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OutOfMemoryError??

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone...this is my problem:
If I start the application with a -db C:\\mydb.db option and mydb.db isn't a valid fly by night services database file (for example an ASCII file), the Data class does:
nFields = db.readInt();
description = new FieldInfo[nfields];
the value of nFields is absolutely wrong, because it contains a large integer value, so when it tries to dim the array description, it throws an OutOfMemoryError!
How I can achieve this behaviour?? I suppose is incorrect to insert in my code a try {} catch (OutOfMemoryError) { }
Thanks...
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some of us added a rudimentary integrity check to our startup code that would prevent this from happening if you opened up other files by mistake. There's another thread that discusses it, but I couldn't find it. Anyway, the code is like this:
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Pete, but...
you can't write in your code
if(headerLen < 0 || nFields != 9 || recordCount < 1)
because in this way you will able to manage a datasource with only 9 field (future enhancements...). The structure of your database is hard-coded and I think it is not very well...
Thanks anyway...
 
A teeny tiny vulgar attempt to get you to buy our stuff
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic