Hi,

You have a memory leak somewhere in you code.
The only way to find out is to use the Windows Task manager or sysinternals
process explorer and look at the column mem delta.

Step thru your code and try to determine which statement is causing the
memory leak. You can do this by comment out lines of code. 
I know this is pain full, but it is the only way.

Regards
EG Utility A/S
Michael Troelsen 

-----Original Message-----
From: Axapta-Knowledge-Village@yahoogroups.com
[mailto:[EMAIL PROTECTED] On Behalf Of axapta123456
Sent: 20. juli 2005 11:57
To: Axapta-Knowledge-Village@yahoogroups.com
Subject: [Axapta-Knowledge-Village] 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 
individually.
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.







Sharing the knowledge on Axapta. 
Yahoo! Groups Links



 






Sharing the knowledge on Axapta. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/Axapta-Knowledge-Village/

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

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


Reply via email to