Bonjour à tous,
Voilà, j'utilise une BD Access local pour effectuer des opérations d'analyses. j'ajoute à cette BD environ 4000 enregistrements chaque jour. Lors de mes analyses je récupère l'ensemble de ma BD dans un DataSet pour ensuite faire mes opérations d'analyse sur l'ensemble des mes enregistrements.
Depuis une semaine je ne suis plus capable de faire l'analyse sur l'ensemble des enregistrments car l'exception System.OutOfMemoryException apparaità environ 90% du travail fait. Voici le message reçu.
J'imagine que je dois libérer de la memoire, j'ai essayé de vider mes datatables après chaque analyse mais ça fonctionne pas. Alors je suis un peu perdu.L'exception System.OutOfMemoryException n'a pas été gérée
Message=Une exception de type 'System.OutOfMemoryException' a été levée.
Source=System.Data
StackTrace:
à System.Data.Common.DoubleStorage.SetCapacity(Int32 capacity)
à System.Data.RecordManager.set_RecordCapacity(Int32 value)
à System.Data.RecordManager.GrowRecordCapacity()
à System.Data.RecordManager.NewRecordBase()
à System.Data.DataTable.NewRecord(Int32 sourceRecord)
à System.Data.DataRow.BeginEditInternal()
à System.Data.DataRow.set_Item(DataColumn column, Object value)
à System.Data.DataRow.set_Item(Int32 columnIndex, Object value)
à BourseV3.ScanMarche.RemplirDatatable(String symb) dans C:\Users\Mario\Documents\Visual Studio 2010\Projects\BourseV3\BourseV3\ScanMarche.vb:ligne 551
à BourseV3.ScanMarche.DoTheTask() dans C:\Users\Mario\Documents\Visual Studio 2010\Projects\BourseV3\BourseV3\ScanMarche.vb:ligne 359
à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
à System.Threading.ExecutionContext.runTryCode(Object userData)
à System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
à System.Threading.ThreadHelper.ThreadStart()
InnerException:
Le bout de code qui suis est utilisé pour charger mes datatables une après l'autre en faire l'analyse et détruire les datatables.
Vos suggestions sont les bienvenus pour régler ou pour améliorer mon code.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 'Action des threads Sub DoTheTask() 'boucle pour modifier les critères d'analyses SyncLock Lock Do Until QuSymbole.Count = 0 'Création de la Datatable Dim SymbA As String = String.Empty Dim Sq As New Dictio Dim Th As String = Thread.CurrentThread.Name Dim Doubl As Boolean = False SymbA = QuSymbole.Dequeue For Each DtTest As DataTable In ObjDataSet.Tables If DtTest.TableName = SymbA Then Doubl = True DtTest.Clear() End If Next If Not Doubl = True Then Sq.Create(Th, SymbA) ObjDataSet.Tables.Add(Sq(Th)) 'Formation des columns MiseEnForme(ObjDataSet.Tables(SymbA)) End If 'Ajouter les données RemplirDatatable(SymbA) 'Analyser le Datatable If ObjDataSet.Tables(SymbA).Rows.Count > 0 Then Dim RCount As Integer = ObjDataSet.Tables(SymbA).Rows.Count - 1 'Calcul de tendences Dim Tend30 As Decimal = TendencePrix(30, SymbA, ObjDataSet.Tables(SymbA)) Dim Tend180 As Decimal = TendencePrix(180, SymbA, ObjDataSet.Tables(SymbA)) Dim Tend360 As Decimal = TendencePrix(360, SymbA, ObjDataSet.Tables(SymbA)) 'Calcule de la variation entre aujourd'hui et hier Dim Var As Double = ObjDataSet.Tables(SymbA).Rows(RCount).Item(9) - ObjDataSet.Tables(SymbA).Rows(RCount - 1).Item(9) Dim VarPC As Double = Var / ObjDataSet.Tables(SymbA).Rows(RCount - 1).Item(9) If ObjDataSet.Tables(SymbA).Rows(RCount).Item(0) = ALDate.Item(ALDate.Count - 1) Then Dim MaStr As String = (ObjDataSet.Tables(SymbA).Rows(RCount).Item(0) & ";" & ObjDataSet.Tables(SymbA).Rows(RCount).Item(1) & ";" & ObjDataSet.Tables(SymbA).Rows(RCount).Item(2) & ";" & ObjDataSet.Tables(SymbA).Rows(RCount).Item(3) & ";" & ObjDataSet.Tables(SymbA).Rows(RCount).Item(5) & ";" & ObjDataSet.Tables(SymbA).Rows(RCount).Item(6) & ";" & ObjDataSet.Tables(SymbA).Rows(RCount).Item(7) & ";" & ObjDataSet.Tables(SymbA).Rows(RCount).Item(8) & ";" & ObjDataSet.Tables(SymbA).Rows(RCount).Item(9) & ";" & Var & ";" & VarPC & ";" & ObjDataSet.Tables(SymbA).Rows(RCount).Item(10) & ";" & Tend30 & ";" & Tend180 & ";" & Tend360) DelListVScan(MaStr) AnalyseSymb(ObjDataSet.Tables(SymbA)) End If End If 'ObjDataSet.Tables(SymbA).Rows.Clear() ObjDataSet.Tables(SymbA).Clear() Loop End SyncLock End Sub
Merci de votre soutien
Mario
Partager