Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Collection is removed from memory after a while
Message
 
 
À
15/11/2013 13:42:54
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01588067
Message ID:
01588073
Vues:
30
I am trying to mentally translate this line Dim loObject(4) As Object

into C# code and I can not. May be because of my not knowing C# well enough.

What this line does in VB.NET?


In C# code I would probably create myImage class instead and use it to add to collection and access properties.


>>It is a strange code. What is loObject(1)? Shouldn't you use loObject.Name instead and other properties?
>>
>>Also, in C# you will need to give a type to the loObject in this code. I don't see a type in your code.
>
>This approach allows to create a collection in two-dimensional array. Thus, each entry in the collection contains several items. I have this all over the framework for years. This has proven to work exceptionnally well so far. So, basically, as the entry in a collection can have multiple types, I have object. So, when the collection is built, it builds up an object and store it in the collection. So, I can scan the collection for the name that I am looking for. Then, I can extract any property I want from it.
>
>The situation that happened an hour ago seems to be related to this:
>
>"By using weak references, cached objects can be resurrected easily if needed or they can be released by garbage collection when there is memory pressure."
>
>So, that would explain why oImage collection had been released from memory because of a memory pressure. As this one is called within an intensive approach, an array seems to be more appropriate for storing about 20 items in that collection.
>
>For your information, this is how the collection is built:
>
>
>        ' If this is the Web site
>        If oApp.nApplicationMode = 3 Then
>
>            ' If we have some images in memory
>            If oApp.oAdmin.oRow("Image").length > 0 Then
>
>                ' Load the application into the string builder
>                loStringBuilderFile.LoadString(oApp.oAdmin.oRow("Image"))
>
>                ' For each image
>                For lnCounter = 1 To loStringBuilderFile.nLine
>
>                    ' Get the line
>                    If Not loStringBuilderFile.MLine(lnCounter) Then
>                        Return False
>                    End If
>
>                    lcImage = loStringBuilderFile.cLine
>
>                    ' If the file exists
>                    If oApp.FileExist(oApp.cGraphicFat + lcImage) Then
>
>                        ' Get the image details making it OK to reender the HTML without flickering
>                        loImage = New System.Drawing.Bitmap(oApp.cGraphicFat + lcImage)
>                        lnWidth = loImage.Width
>                        lnHeight = loImage.Height
>
>                        AddImage(lcImage, lnWidth, lnHeight)
>                    Else
>                        AddError(oApp.cGraphicFat + lcImage + " does not exist.")
>                    End If
>
>                Next
>
>            End If
>
>        End If
>
>
>...and the AddImage() method:
>
>
>    ' Add an image in the collection
>    ' expC1 Name
>    ' expN1 Width
>    ' expN2 Height
>    Private Function AddImage(ByVal tcName As String, ByVal tnWidth As Integer, _
>     ByVal tnHeight As Integer) As Boolean
>        Dim lcExtension As String = ""
>        Dim lcName As String = ""
>        Dim lnLocation As Integer = 0
>        Dim loObject(4) As Object
>
>        ' Initializaiton
>        lcName = Trim(tcName)
>        lnLocation = oApp.At(".", lcName)
>
>        ' If we have found it
>        If lnLocation > 0 Then
>
>            ' If this is not the last character
>            If lnLocation < lcName.Length Then
>                lcExtension = Mid(lcName, lnLocation + 1)
>            End If
>
>        End If
>
>        ' Initialization
>        loObject(1) = lcName
>        loObject(2) = tnWidth
>        loObject(3) = tnHeight
>        loObject(4) = lcExtension
>
>        oApp.oImage.Add(loObject)
>
>        Return True
>    End Function
>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform