Login Page - Create Account

Support Board


Date/Time: Tue, 07 May 2024 11:23:18 +0000



Post From: Sierra crash on multiple charts using Dynamic Memory Allocations Within Study Instance

[2015-06-08 20:56:56]
wwwingman - Posts: 185
Hi

I need persistence between study call so followed the instructions in the documentation on the Dynamic Memory Allocations Within Study Instance.
( http://www.sierrachart.com/index.php?page=doc/doc_ACSILProgrammingConcepts.html#DynamicMemoryAllocations ).

However, something seem to go wrong when I use the DLL on multiple charts. And it crashes SierraCharts.

Here is the simples sequence that systematically crashes my sierra :
1. Compile the a skeleton with the code below (The code comes from the documentation, I have not modified it).
2. Open Chart #1. Add the skeleton DLL.
3. Duplicate Chart #1 (=> Chart #2).
4. Close Chart #1.
5. Close Chart #2.
6. Sierra crashes.

Tested on 1259 and 1261 versions.

Please advise.

-- W.

The code of the skeleton :

#include "sierrachart.h"

SCDLLName("SierraSkeleton")

SCSFExport scsf_DynamicMemoryAllocationExample(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    sc.GraphName = "Dynamic Memory Allocation Example";
    sc.AutoLoop = 1;

    sc.FreeDLL = 0;

    return;
  }

  double * p_DoubleArray = (double*)sc.GetPersistentPointer(1);

  if(sc.LastCallToFunction)
  {
    if(p_DoubleArray != NULL)
    {
      sc.FreeMemory( p_DoubleArray);
      sc.SetPersistentPointer(1, NULL);
    }

    return;
  }

  if(p_DoubleArray == NULL)
  {
    p_DoubleArray = (double *) sc.AllocateMemory( 1024 * sizeof(double) );

    if(p_DoubleArray != NULL)
      sc.SetPersistentPointer(1, p_DoubleArray);
    else
      return;
  }

  p_DoubleArray[0] = 100;

  return;
}

Date Time Of Last Edit: 2015-06-08 20:57:38