https://bugs.documentfoundation.org/show_bug.cgi?id=152613

            Bug ID: 152613
           Summary: Macro Basic: RAM isn't deallocated when macro is
                    finished
           Product: LibreOffice
           Version: 7.6.0.0 alpha0+ Master
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: [email protected]
          Reporter: [email protected]

Run LibreOffice and run some RAM Watcher - I use standard Task Manager via
Ctrl+Alt+Del in Win10. 
Run macro devourRAM (it does recursion for array of various sub-arrays) for
example only from Basic Editor - it isn't so fast, so it shows progressbar. It
takes about 0,5 GB RAM. Check it in RAM Watcher. 
When macro will finish, the RAM will stay occupied :-(. You can close Basic IDE
to have only LibreOffice Starter, but RAM is occupied. 
After you close whole LibreOffice then RAM is deallocated. 

-------------------

private gi&, gpOut() 'index and array for result

Sub devourRAM
        dim oDoc as object, i&, p(), oStatusbar, iStep&
        const j=20000 'increase this to devour more RAM
        oStatusbar=getController.StatusIndicator
        oStatusbar.start("It isn't so fast :-(", j)

        p=array(1, 2, 3, array(1, 2, 3, array(1, 2, 3), 4, array(1, 2, 3), 4,
array(1, array(2, 3))), 4, array(1,2,3), array(1, 2, array(1,2), 3), _
                array(1, 2, 3, array(1, 2, 3, array(1, 2, 3), 4, array(1, 2,
3), 4, array(1, array(2, 3))), 4, array(1,2,3), array(1, 2, array(1,2), 3) ), _
                array(1, 2, 3, array(1, 2, 3, array(1, 2, 3), 4, array(1, 2,
3), 4, array(1, array(2, 3))), 4, array(1,2,3), array(1, 2, array(1,2), 3) ), _
                array(1, 2, 3, array(1, 2, 3, array(1, 2, 3), 4, array(1, 2,
3), 4, array(1, array(2, 3))), 4, array(1,2,3), array(1, 2, array(1,2), 3) ), _
                array(1, 2, 3, array(1, 2, 3, array(1, 2, 3), 4, array(1, 2,
3), 4, array(1, array(2, 3))), 4, array(1,2,3), array(1, 2, array(1,2), 3) ) )
        redim gpOut(130)
        for i=1 to j
                gi=0
                recurArray(p, "") 'recursion
                iStep=iStep+1 'for statusbar
                if iStep=10 then 'set new value
                        oStatusbar.setValue(i)
                        iStep=0
                end if          
        next i
        oStatusbar.reset
        gi=0
        gpOut()=0
End Sub

Function recurArray(level as variant, s$) 'recursion for reading the
sub-arrays, output to global array gpOut
        dim i&
        if level(0)>0 then 'for the count of current word
                gpOut(gi)=array( s, level(0) ) 'add to global output array
                gi=gi+1
        end if
        for i=1+lbound(level) to ubound(level) 'next indexes in level
                if isArray(level(i)) then
                        recurArray(level(i), s & i) 'get sub-level
                else
                        gpOut(gi)=array( s, level(0) ) 'add to global output
array
                        gi=gi+1
                end if
        next i
End Function

Function getController() as object 'get oDoc.CurrentController for progressbar,
also if only Basic IDE is running
        dim oDoc as object
        oDoc=ThisComponent
        if
isNull(CreateUnoService("com.sun.star.reflection.CoreReflection").getType(oDoc))
OR _
       
isNull(CreateUnoService("com.sun.star.script.Invocation").createInstanceWithArguments(array(oDoc)))
then 'regular oDoc isn't, try to get other Libre window like Basic editor

                dim oComponents as object, oComponent as object
                oComponents=StarDesktop.Components.CreateEnumeration
                while oComponents.hasMoreElements 'try all Libre windows
                        oComponent=oComponents.NextElement
                        if oComponent.Identifier="com.sun.star.script.BasicIDE"
then 'Basic Editor is active
                                getController=oComponent.CurrentController
                                exit function
                        end if
                wend
                oDoc   
=StarDesktop.LoadComponentFromUrl("private:factory/swriter", "_blank", 0,
array()) 'open new document in Writer for progressbar
        else
                getController=oDoc.CurrentController
        end if
End Function

-----------------

Tested in:
Version: 7.4.3.2 (x64) / LibreOffice Community
Build ID: 1048a8393ae2eeec98dff31b5c133c5f1d08b890
CPU threads: 8; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: cs-CZ (cs_CZ); UI: cs-CZ
Calc: CL

Version: 7.6.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: ad387d5b984c6666906505d25685065f710ed55d
CPU threads: 8; OS: Windows 10.0 Build 17763; UI render: Skia/Raster; VCL: win
Locale: cs-CZ (cs_CZ); UI: en-US
Calc: CL threaded

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to