We are developing a customised ArcPad Windows Mobile 6 application for utiliy industry. There are many layers - like Primary Conductor, Transformer, SEcondary Conductor etc which we are exporting as Background layers in AXF. There are some other 4 feature layers used for capturing data points in the field. Also we developed a custom arcPad form.
At each location we are adding many units in the same form. These are not connected to any database fields. We push the data to the database when the user clicks OK.
Besides we also have an applet with different tools and we also have different eventhandler code for the events associated with Map and GPS - like new feature added, on featuredeleted, onpointerdown etc.
But we are facing a memory issue in our application. When the memory consumption of ArcPad reaches 16.5 MB we start getting low memory warning and the map does not refresh properly. Even the map navigator sometimes does not show.
I also found that whenever I push data in the AXF tables through VBScript the memory consumption jumps by around 1 MB. But if the data is pushed through native forms without using any script the memory consumption does not increase.
So I want to know what is the best way to push data in AXF and what can be a better way way to handle the low memorywarnings. Also when the GPS is on the application becomes very slow.
.
Below is one method where there is memory leak. Even if I use Recordset AddNew method to add the record still the same behavior.
Sub SaveUnits
Dim strSQL,nRecords,feature, unitsDatasource,locationForm,mode,unitsLayer,unitsRecords,comments,objid, delObj
Set unitsLayer = Map.layers("GPSUnits")
Set unitsDatasource = Application.Map.Layers("GPSUnits").DataSource
Set locationForm = Map.Layers("GPSLocations").forms("EDITFORM")
mode = locationForm.Mode
If mode=3 then
Application.UserProperties ("NewlocationX") = locationForm_X
Application.UserProperties ("NewlocationY") = locationForm_Y
Application.UserProperties ("NewlocationID") = locationID
for each feature in existingAssemblies
strSQL="insert into GPSUnits(CLASSNAME,QUANTITY,STATUS,LOCATIONID,NAME,BEHAVIOR,SHAPE_X,SHAPE_Y,AXF_TIMESTAMP,AXF_STATUS,COMMENTS,Type,JOBID) values ('" &_
feature(3) & "'," & feature(1) & ",'" & feature(2) & "'," & locationID & ",'" & feature(0) & "','" & feature(5) & "'," & locationForm_X & "," &_
locationForm_Y & ",'" & Now & "',1,'"& feature(6) & "','"& feature(7) & "','" & Application.UserProperties("JobID") & "')"
nRecords = unitsDatasource.Execute(strSQL)
Next
else
for each feature in existingAssemblies
comments = feature(6)
if comments = null then
comments = ""
end if
objid = feature(4)
if IsNull(objid) then
strSQL="insert into GPSUnits(CLASSNAME,QUANTITY,STATUS,LOCATIONID,NAME,BEHAVIOR,SHAPE_X,SHAPE_Y,AXF_TIMESTAMP,AXF_STATUS,COMMENTS,Type,JOBID) values ('" &_
feature(3) & "'," & feature(1) & ",'" & feature(2) & "'," & Application.UserProperties ("locationID") & ",'" & feature(0) & "','" & feature(5) & "'," & locationForm.Fields.Shape.X & "," &_
locationForm.Fields.Shape.Y & ",'" & Now & "',1,'"& feature(6) & "','"& feature(7) &"','" & Application.UserProperties("JobID") & "')"
nRecords = unitsDatasource.Execute(strSQL)
else
strSQL = "update GPSUnits Set QUANTITY = " & feature(1) & ",STATUS = '" & feature(2) & "',COMMENTS = '" & comments & "' where AXF_OBJECTID= "& feature(4)
nRecords = unitsDatasource.Execute(strSQL)
end if
Next
for each feature in deletedAssemblyList
delObj = feature(4)
if Not (IsNull(delObj)) then
strSQL = "Delete from GPSUnits where AXF_OBJECTID= "& feature(4)
nRecords = unitsDatasource.Execute(strSQL)
End if
Next
End if
Map.Refresh(true)
Application.Map.Layers("GPSLocations").Properties ("ShowEditForm") = True
Set unitsLayer = Nothing
Set unitsDatasource=Nothing
Set locationForm = Nothing
End Sub
Can anyone point me out how can I optimise the above method. We are going to take a decision on the application based on the memory leak issue.
Thanks for helping
Suman