Re: Weird exception thrown
Frans Bouma <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <001501c974df$605a7600$210f6200$@nl> |
> I did not see my original post and your reply. I wonder if this message will > reach you. I will copy your private e-mail address too. > > Could you repost and also copy me? I don't know why some of these messages > do not reach me. See: > I have an application that reads an XML file, parses it and saves its > data into an Oracle database. The save is actually an insert, if the > record doesn't exist or an update if the record exists. In order to > figure out which operation I have to perform, I execute a select, to > check whether the record is already in the database. I build the > Select SQL statement, create an Oracle Command object with it and then call its Execute Reader method. > This method returns an OracleDataReader object and for that, all I > care to check is to see whether it has any records. The > OracleDataReader class has a property called "HasRows" that will tell me just that. > I know what you are thinking: I should ask this question on a > different forum, like one Oracle hosts for their ODP.NET development, > but bare with me for a second. > After running for 2-3 days continuously, my application starts > throwing this weird exception where it says that "Memory could not be > allocated". I managed to trace the raise of the exception to the > invocation of the "HasRows" property for the OracleDataReader object. > The problem is that, looking at the documentation, that property is > not raising any exceptions, so what the heck is going on. > To keep things under control, I even tried to kick in the garbage > collection > (GC.Collect()) myself, every now and then. Now the exception takes > longer to be triggered, but eventually it is triggered. > Can anyone give me some ideas as to what else to try and figure out > what the problem is? The XML files are not really big, averaging around 100 kB each. > When the exception is triggered, I look ion the task manager and > Physical Memory usage is nowhere near the top. > Any suggestion will be highly appreciated. Oracle's ODP.NET is actually a wrapper around their java CLI code, so it has unmanaged elements everywhere, even OracleParameter objects have unmanaged elements. This means that you have to call Dispose() on - OracleParameter - OracleDataReader - OracleCommand - OracleConnection It's not enough to call Dispose on OracleConnection or OracleCommand, nor is it enough to call Close on OracleDataReader. If you don't do this, you'll get subtle memory leaks which eventually will bring the system down. As you're using Oracle, you can do without the select however, use the MERGE statement: http://www.fast-track.cc/10g_166.htm If you're on 9i you can use an upsert: http://www.praetoriate.com/oracle_tips_upserts.htm If you're on an even older dinosaur (poor sod ;)), you're out of luck and will have to use the select separately. Good luck. FB =================================== View archives and manage your subscription(s) at http://peach.ease.lsoft.com/archives