Xojo Conferences
XDCMay2019MiamiUSA

[MBS] Leaking with CFDictionary (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: Re: [MBS] quicktime audio stream URL doesn't load
Next thread: Re: [MBS] render content of rtf file as image (bitmag/jpg)


Re: [MBS] MBS Icon Routines redefined?   -   Garth Hjelte
  [MBS] Leaking with CFDictionary   -   Beatrix Willius
   Re: [MBS] Leaking with CFDictionary   -   Christian Schmitz

[MBS] Leaking with CFDictionary
Date: 03.04.11 17:50 (Sun, 3 Apr 2011 18:50:49 +0200)
From: Beatrix Willius
Was playing around with Instruments and it told me that the following code is leaking a kb per call. Any idea what could cause this?

Using almost latest beta of MBS with RB 2011r5 on Mac OS 10.6.4.

Private Function ConvertDictionary(Dict As Dictionary) As CFDictionaryMBS

'convert a dictionary to a CFDictionary

Dim theCFDictionary As CFMutableDictionaryMBS
Dim CFKey, CFValue As CFObjectMBS
Dim Key, Value As Variant
Dim currentValue As Integer

theCFDictionary = NewCFMutableDictionaryMBS

//Determine the key type and make it a CFObject
For currentValue = 0 to Dict.Count - 1
Key = dict.key(currentValue)
Select Case VarType(Key)
Case 11 //Boolean
CFKey = NewCFBooleanMBS(Key.BooleanValue)
Case 2 //Integer
CFKey = NewCFNumberMBSInteger(Key.IntegerValue)
Case 5 //Double/Single
CFKey = NewCFNumberMBSDouble(Key.DoubleValue)
Else // Make it a string
CFKey = NewCFStringMBS(Key.StringValue)
End Select

//Determine the value and make it a CFObject
Value = dict.value(dict.key(currentValue))
Select Case VarType(Value)
Case 11 //Boolean
CFValue = NewCFBooleanMBS(Value.BooleanValue)
Case 2 //Integer
CFValue = NewCFNumberMBSInteger(Value.IntegerValue)
Case 5 //Double/Single
CFValue = NewCFNumberMBSDouble(Value.DoubleValue)
Case 9 //Object (Dictionary?)
If value IsA Dictionary Then
// Make our Dictionary into a theCFDictionaryictionary
CFValue = ConvertDictionary(Value)
Else
//Put handlers here for other objects
End If
case 4104 'string array
CFValue = ConvertArray(Value)
Else // Make it a string - should be the default option if all else fails.
CFValue = NewCFStringMBS(Value.StringValue)
End Select

theCFDictionary.Add CFKey, CFValue
Next
Return theCFDictionary

End Function


Mit freundlichen Grüßen/Regards

Trixi Willius

http://www.mothsoftware.com
Mail Archiver X: archive, clean and search email
http://www.beatrixwillius.de
Fractals, 3d landscapes etc.

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] Leaking with CFDictionary
Date: 03.04.11 19:36 (Sun, 3 Apr 2011 20:36:10 +0200)
From: Christian Schmitz

On 03.04.2011, at 18:50, Beatrix Willius wrote:

> Was playing around with Instruments and it told me that the following code is leaking a kb per call. Any idea what could cause this?

First, do you have a test project for this?
And second, CFDictionaryMBS has a constructor to take a dictionary.

Greetings
Christian