GIS development-SDE connection release

Source: Internet
Author: User

Writing element records to personal GDB or sde gdb is a very simple task, but it seems that when there are too many cases, writing data is too simple, making manyCodeProblems, especially the problems and errors of the ArcSDE itself, cannot be exposed, and many people have never realized similar problems. I have been doing similar work recently, and it seems that it is not difficult to write code, but the test is almost doomed, and there are countless problems and headaches.

1. Efficiency of inserting records
There are two ways to insert records into element classes: one is ifeature. store, and ifeaturecursor. insert (ifeaturebuffer) and ifeaturecursor. the flush method, obviously, is faster than the former because the latter method uses the cache.

2. insert records into MDB and SDE element classes
When inserting data into these two types of element classes, you do not need to use the iworkspaceedit interface to enable or disable a session. However, if the SDE element class is registered as version, this interface must be used, otherwise the CPU will be up to 100%, and the error "the operation in invalid on a closed state" will pop up. I used a version of Sde element class, and encountered a lot of crashed SDE errors, such as fdo_e_se_db_io_error and fdo_e_se_out_of_locks.

3. When multiple MDB are imported into one mdb, if the iworkspaceedit interface is used, several layers cannot be opened using ArcMAP or arccatalog, that isProgramInstead of using this interface, the loading process of the same code is normal.

4. when two or more MDB are imported into one MDB and then to the second mdb, it is very likely that "** _ shape_index is occupied" is caused by writing.. NET platform code, because the cursor that you traverse or insert data is not released. Pfeaturecursor = NULL; the object is not cleared from the memory, because. the net platform uses runtime to collect garbage. It does not directly destroy COM objects like VC or VB. In this case, you should use system. runtime. interopservices. marshal. the releasecomobject method is used to forcibly release COM objects to remove the exclusive state of a table.

Questions about releasing SDE connections

If we try to load a large amount of data into SDE using AO code, such as 0.5 million records per layer and 30 layers in total, this process is a nightmare, you may encounter many incredible problems. In general, if a problem occurs, the fdoerr number is always reported. We can also check the problem. However, if the problem number is of the SDE error type, it's hard to say. You may find that the entire network has never been seen in some situations, that is, an isolated instance. For exampleFdo_e_se_db_io_errorAndFdo_e_se_out_of_locks.

I frequently encounter this problem when writing code to SDE to import data.Fdo_e_se_db_io_errorAlthough the Safe Website provides three possible causes for the problem, I have never been able to solve it from the Oracle perspective. Count the successful data import to SDE. Each time a feature class is imported, a dedicated gsrvr process is enabled for each feature class. The success rate is the highest, almost 95%. 10% of failure is to import 2 million annotation element classes at a time, but the islands are separated, and every time 0.5 million entries are imported, everything is fine.

Then the problem arises. We know that after SDE is installed, there is a giomgr process between SDE and DBMS responsible for managing the communication process between the two parties, that is, the gsrvr process is established according to the access request. Generally, gsrvr processes Sde-related queries, storage, and deletion operations, and can process multiple connection requests. The relationship between gsrvr and DBMS is "general rules are not painful, the general rule is not painful. "Once the amount of data transmitted is too large, gsrvr will start to take off. Our problem is how to release the connection after a element class is processed, that is, to close the gsrvr process and create a new gsrvr process at the beginning of the next element class. This method is indeed the safest.

Now the problem is how to release the SDE connection. In fact, if you use a pure COM object to write, this is almost no problem. Some people think that you can set the workspace object to null. For example, we can write a VB code:
Dim pfws as ifeatureworkspace
Set pfws = sdeworkspacefactory. open () '1
Set pfws = nothing '2

Let's look at the Oracle connection. After 1 is executed, there should be two SDE links. After 2 is executed, there will be only one SDE link, and its owner is giomgr. Apparently, the SDE connection is closed.

In. in the. NET platform, this set pfws = nothing does not work. We have to use system. runtime. interopservices. marshal. releasecomobject (pfws); To clear unmanaged code in memory. Try it. You can also find that the SDE connection is closed.

The problem is more complicated. If we traverse a element class in pfws, we will find that even if we use system. runtime. interopservices. marshal. releasecomobject (pfws); the solution is to use system for all the new Ao objects in the code. runtime. interopservices. marshal. the releasecomobject method is used to release objects generated by certain loops, such:
Pfeature = pfeaturecursor. nextfeature ();
While (pfeature! = NULL)
{
System. runtime. interopservices. Marshal. releasecomobject (pfeature );
Pfeature = pfeaturecursor. nextfeature ();
}
System. runtime. interopservices. Marshal. releasecomobject (pfeaturecursor );
It must also be destroyed. If an object related to the SDE database is not destroyed, there are still two SDE connections.

After using this method to layer a gsrvr process, no moreFdo_e_se_db_io_errorProblem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.