Hi

The code below is taken from the Global class in Ax 3.0 SP4. It might cure
your problem

static void SmartHeapMemorySizeUp(boolean _silent = true)
{
    HeapCheck   hc;
    int         i, pageSize, newPageSize, physMem, minPageSize;
    Container   memStatus;
    ;

    memStatus = WinApi::getMemoryStatus();
    physMem = conpeek(memStatus,3)/1024/1024;
    minPageSize = min(32768,physMem * 32);
    setprefix(funcName());
    if (!_silent)
    {
        info(strfmt("Physical Memory = %1 MB", physMem));
        info(strfmt("Minimum page size = %1 Bytes", minPageSize));
    }

    hc = new HeapCheck();
    i = hc.poolCount();
    while (i>0)
    {
        setprefix(strfmt("Pool no = %1", i));
        if (!_silent)
        {
            info(strfmt("FixedBlockSize = %1", hc.fixedBlockSize(i)));
            info(strfmt("SmallBlockSize = %1", hc.smallBlockSize(i)));
        }

        pageSize = hc.pageSize(i);
        newPageSize = pageSize;
        while (newPageSize < minPageSize)
        {
            newPageSize = 2 * newPageSize;
        }
        if (!_silent)
        {
            info(strfmt("Old PageSize = %1", pageSize));
            info(strfmt("New PageSize = %1", newPageSize));
        }

        hc.pageSize( i, newPageSize );
        i--;
    }
}

Kind regards
Bruno

  _____ 

From: development-axapta@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of axapta123456
Sent: 20. juli 2005 12:00
To: development-axapta@yahoogroups.com
Subject: [development-axapta] Out Of Memory Error


I get the SmartHeap Out of Memory error when trying to import and
post individual sales orders from an external system.

The outline of the process is as follows:

Class1: A batchable class

static void main(Args args)
{
    Class1 class1;
    boolean  importRunning = true;
    ;

    class1 =  class1::construct();
   
    if(class1.prompt())
    {       
        while (importRunning)
        {
            importRunning = class1.runImport();
            class1.Finalize();
            class1 = class1::construct();
        }
    }
}

The class1.runImport() runs through an external file and for each
line in the external file creates a container that is packed and send
to a static method in Class2, that will import and post the external
file line:

convertedCon = this.convertToPackedObject(con);
convertedCon = this.pack();
returnImportAndPost = Class2::importAndPost(convertedCon);

Class2: Import and Post one line in the file

static container importAndPost(container invoiceDetailValues)
{
    #define.CurrentVersion(5)

    Class2 class2 = new Class2();
    ;

    class2.unpack(invoiceDetailValues);
    class2 = class2.getPostedDate();

    invoiceDetailValues = connull();
    validAccounntType = invoiceDetail.validateAccountType();

    if (validAccounntType)
    {
        ttsbegin;
        // Import an invoce detail line
        toPostSalesId = class2.Import(invoiceDate);

        // If the import returns a blank sales ID, the import failed
        if (toPostSalesId != "")
            posted = class2.Post(toPostSalesId, invoiceDate);
        ttscommit;
    }
    else
    {
        // The invoice detail line does not have a valid account type
        returnvalues = class2.populateReturnContainer(false,
toPostSalesId, invoiceDate, 0.00, class2.getErrorMessage());
        class2.Finalize();
        return returnvalues;
    }

    returnvalues = class2.populateReturnContainer(posted,
toPostSalesId, invoiceDate, class2.getTotalCharges(),
class2.getErrorMessage());
    class2.Finalize();
    return returnvalues;
}

Both Class1 and Class2 contains the following localmacros and pack()
and unpack():

#define.CurrentVersion(5)

#localmacro.CurrentList1
a1,
a2,
//... 26 elements
a48
#endmacro

#localmacro.CurrentList2
b1,
b2,
//... 18 elements
b48
#endmacro

#localmacro.CurrentList3
c1,
c2,
//... 41 elements
c48
#endmacro

public container pack()
{
     return [#CurrentVersion,
              [#CurrentList1],
              [#CurrentList2],
              [#CurrentList3]];
}

public boolean unpack(container packedClass)
{
     int version = runbase::getVersion(packedClass);
     Container con;
     Container con1;
     Container con2;
     Container con3;

     switch (version)
     {
     case #CurrentVersion:
         [version,con1,con2,con3,con] =packedClass;
         [#CurrentList1] = con1;
         [#CurrentList2] = con2;
         [#CurrentList3] = con3;
     return true;
     default : return false;
     }   

     return false;
}


Each external file contains 1000 lines to be imported and posted.
Batching is implemented in the class1.runImport() method and the
batches has a size of 100.
The memory error occurs approximately after 3 files.
The transaction in the Class2::importAndPost method is the only
transaction used in the process.
The Finalize() methods in Class1 and Class2 are empty.
The SmartHeapMemorySizeUp() has been tested and does not resolve the
out of memory error.








SPONSORED LINKS
Computer
<http://groups.yahoo.com/gads?t=ms&k=Computer+part&w1=Computer+part&w2=Progr
amming+languages&w3=Microsoft+axapta&w4=Support+exchange&c=4&s=90&.sig=yLpvc
LTIDJ5FTkRJGsO11w> part       Programming
<http://groups.yahoo.com/gads?t=ms&k=Programming+languages&w1=Computer+part&
w2=Programming+languages&w3=Microsoft+axapta&w4=Support+exchange&c=4&s=90&.s
ig=cuhEClK4dU4wapXFmKisbQ> languages       Microsoft
<http://groups.yahoo.com/gads?t=ms&k=Microsoft+axapta&w1=Computer+part&w2=Pr
ogramming+languages&w3=Microsoft+axapta&w4=Support+exchange&c=4&s=90&.sig=yf
eG_U6QaLfPOZZIud02Fg> axapta      
Support
<http://groups.yahoo.com/gads?t=ms&k=Support+exchange&w1=Computer+part&w2=Pr
ogramming+languages&w3=Microsoft+axapta&w4=Support+exchange&c=4&s=90&.sig=hy
8yRGMzrmxdphyITTUeqA> exchange      

  _____ 

YAHOO! GROUPS LINKS


     
*      Visit your group "development-axapta
<http://groups.yahoo.com/group/development-axapta> " on the web.
 

*      To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
 

*      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
<http://docs.yahoo.com/info/terms/> .


  _____ 




[Non-text portions of this message have been removed]





YAHOO! GROUPS LINKS




Reply via email to