<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SAS Functions called in FCMP Functions from DS2 Packages Error: &amp;quot;Freeing Memory Not Allocat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681449#M206120</link>
    <description>&lt;P&gt;I've not used DS2 except once or twice just to see if it might be a better option than a traditional Data step for a particular project.&amp;nbsp; My experiments with DS2 have uniformly been disappointing.&amp;nbsp; A traditional Data step is almost always faster unless you have a process that is highly CPU bound.&amp;nbsp; If it helps, Troy Martin Hughes wrote a &lt;A href="https://www.pharmasug.org/proceedings/2019/AD/PharmaSUG-2019-AD-228.pdf" target="_blank" rel="noopener"&gt;PharmaSUG paper&lt;/A&gt; that discusses when DS2 actually runs faster than a traditional Data step.&amp;nbsp; When I attended WUSS 2018, one of the speakers said that to his knowledge DS2 really hasn't become popular and that not very many people are using it.&amp;nbsp; My sense is that DS2 has a very narrow range in which it is actually a better option than a traditional Data step or Proc SQL.&amp;nbsp; Incidentally, parallel processing can be done with traditional Data steps either via an rSubmit or via a SYSTASK.&amp;nbsp; However, I think you are interested in DS2 because of it's syntax rather than in its performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I don't have vast experience from which to draw on re DS2, but I can confirm that an error results.&amp;nbsp; See log below.&amp;nbsp; You may want to do as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;suggests and open a ticket with SAS.&lt;/P&gt;
&lt;PRE&gt;String to Trim                                                                                      
ERROR: Access violation
ERROR: General error
NOTE: PROC DS2 has set option NOEXEC and will continue to prepare statements.
84         quit;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE DS2 used (Total process time):
      real time           0:00:00.28
      cpu time            0:00:00.28
      Timestamp           September 03, 2020 12:52:30&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Sep 2020 18:07:12 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2020-09-03T18:07:12Z</dc:date>
    <item>
      <title>SAS Functions called in FCMP Functions from DS2 Packages Error: "Freeing Memory Not Allocated  Pool"</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681194#M206020</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a complicated one, so I really appreciate anybody who gets through it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am learning DS2 and FCMP and how they interact.&amp;nbsp; I have found problems with many Data Step functions (I have tested STRIP TRIM and LENGTH), if used in an FCMP package which is then referenced in a DS2 package.&amp;nbsp; &amp;nbsp;If a method is defined that uses the function, but it is not called in DS2, the code will run, but then crash with the a dump starting with "ERROR: Freeing Memory Not Allocated Pool [000000000E782200] Value [000000000E391640] tkFnc pool."&amp;nbsp; If the DS2 method using the function is actually called, that method does not run and I get "ERROR: Invalid instruction" followed by the previously mentioned error.&amp;nbsp; It will also frequently crash the SAS session.&amp;nbsp; This happens in traditional SAS and EG, although EG doesn't show the dump.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tested using the SAS functions (Trim) directly in the DS2 method and it works fine.&amp;nbsp; I also still get the error if the FCMP functions don't have parameters and just use a hardcoded string in the function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know if this is a bug, or if I am completely missing the way these new features work.&amp;nbsp; I do a lot of .NET programming and am really hoping for an object oriented approach to SAS programming.&amp;nbsp; I would love to ditch MACRO code as much as possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example piece of code.&amp;nbsp; My application is much more complicated, but it boils down to this.&amp;nbsp; This code works as is.&amp;nbsp; If you uncomment the commented sections in the code you should get the errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname sas_ds2 "C:\Temp\ggg";&lt;BR /&gt;libname base '.';&lt;/P&gt;&lt;P&gt;proc fcmp outlib=base.fcmpsubs.sql_tools ;&lt;BR /&gt;function without_trim($ myVal) $ 100;&lt;BR /&gt;length outvar $ 100;&lt;BR /&gt;outvar = myVal;&lt;BR /&gt;return(outvar);&lt;BR /&gt;endsub;&lt;BR /&gt;&lt;BR /&gt;function with_trim($ myVal) $ 100;&lt;BR /&gt;length outvar $ 100;&lt;BR /&gt;outvar = trim(myVal);&lt;BR /&gt;return(outvar);&lt;BR /&gt;endsub;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;proc ds2;&lt;BR /&gt;package sql_tools / overwrite=yes language='fcmp' table='base.fcmpsubs';&lt;BR /&gt;run;&lt;BR /&gt;package sas_ds2.dataset_info/overwrite=yes;&lt;BR /&gt;dcl package sql_tools st();&lt;BR /&gt;method getUnTrimmed() returns char(100);&lt;BR /&gt;declare char(100) tempStr;&lt;BR /&gt;tempStr = st.without_trim('String to Trim ');&lt;BR /&gt;return tempStr;&lt;BR /&gt;end;&lt;BR /&gt;* If this is uncommented, you should get the crash dump after the code runs;&lt;BR /&gt;/*&lt;BR /&gt;method getTrimmed() returns char(100);&lt;BR /&gt;declare char(100) tempStr;&lt;BR /&gt;tempStr = st.with_trim('String to Trim ');&lt;BR /&gt;return tempStr;&lt;BR /&gt;end;&lt;BR /&gt;*/&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data _null_ ;&lt;BR /&gt;declare package sas_ds2.dataset_info f;&lt;BR /&gt;declare char(100) varlistOut;&lt;BR /&gt;method init();&lt;BR /&gt;f = _new_ sas_ds2.dataset_info();&lt;BR /&gt;varlistOut = f.getUnTrimmed();&lt;BR /&gt;put varlistOut;&lt;BR /&gt;* If this and the previous block are uncommented, this step&lt;BR /&gt;does not run and the you get a crash dump;&lt;BR /&gt;/*&lt;BR /&gt;varlistOut = f.getTrimmed();&lt;BR /&gt;put varlistOut;&lt;BR /&gt;*/&lt;BR /&gt;end;&lt;BR /&gt;enddata;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 01:03:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681194#M206020</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-03T01:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Functions called in FCMP Functions from DS2 Packages Error: "Freeing Memory Not Allocat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681232#M206039</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;crash with the a dump starting with "ERROR: Freeing Memory Not Allocated Pool [000000000E782200] Value [000000000E391640] tkFnc pool."&amp;nbsp;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;When you start seeing that sort of message, an email to Tech Support is not far behind....&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 05:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681232#M206039</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-09-03T05:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Functions called in FCMP Functions from DS2 Packages Error: "Freeing Memory Not Allocat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681373#M206082</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339357"&gt;@CurtisMackWSIPP&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a complicated one, so I really appreciate anybody who gets through it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am learning DS2 and FCMP and how they interact.&amp;nbsp; I have found problems with many Data Step functions (I have tested STRIP TRIM and LENGTH), if used in an FCMP package which is then referenced in a DS2 package.&amp;nbsp; &amp;nbsp;If a method is defined that uses the function, but it is not called in DS2, the code will run, but then crash with the a dump starting with "ERROR: Freeing Memory Not Allocated Pool [000000000E782200] Value [000000000E391640] tkFnc pool."&amp;nbsp; If the DS2 method using the function is actually called, that method does not run and I get "ERROR: Invalid instruction" followed by the previously mentioned error.&amp;nbsp; It will also frequently crash the SAS session.&amp;nbsp; This happens in traditional SAS and EG, although EG doesn't show the dump.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tested using the SAS functions (Trim) directly in the DS2 method and it works fine.&amp;nbsp; I also still get the error if the FCMP functions don't have parameters and just use a hardcoded string in the function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know if this is a bug, or if I am completely missing the way these new features work.&amp;nbsp; I do a lot of .NET programming and am really hoping for an object oriented approach to SAS programming.&amp;nbsp; I would love to ditch MACRO code as much as possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example piece of code.&amp;nbsp; My application is much more complicated, but it boils down to this.&amp;nbsp; This code works as is.&amp;nbsp; If you uncomment the commented sections in the code you should get the errors.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname sas_ds2 "C:\Temp\ggg";&lt;BR /&gt;libname base '.';&lt;/P&gt;
&lt;P&gt;proc fcmp outlib=base.fcmpsubs.sql_tools ;&lt;BR /&gt;function without_trim($ myVal) $ 100;&lt;BR /&gt;length outvar $ 100;&lt;BR /&gt;outvar = myVal;&lt;BR /&gt;return(outvar);&lt;BR /&gt;endsub;&lt;BR /&gt;&lt;BR /&gt;function with_trim($ myVal) $ 100;&lt;BR /&gt;length outvar $ 100;&lt;BR /&gt;outvar = trim(myVal);&lt;BR /&gt;return(outvar);&lt;BR /&gt;endsub;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;proc ds2;&lt;BR /&gt;package sql_tools / overwrite=yes language='fcmp' table='base.fcmpsubs';&lt;BR /&gt;run;&lt;BR /&gt;package sas_ds2.dataset_info/overwrite=yes;&lt;BR /&gt;dcl package sql_tools st();&lt;BR /&gt;method getUnTrimmed() returns char(100);&lt;BR /&gt;declare char(100) tempStr;&lt;BR /&gt;tempStr = st.without_trim('String to Trim ');&lt;BR /&gt;return tempStr;&lt;BR /&gt;end;&lt;BR /&gt;* If this is uncommented, you should get the crash dump after the code runs;&lt;BR /&gt;/*&lt;BR /&gt;method getTrimmed() returns char(100);&lt;BR /&gt;declare char(100) tempStr;&lt;BR /&gt;tempStr = st.with_trim('String to Trim ');&lt;BR /&gt;return tempStr;&lt;BR /&gt;end;&lt;BR /&gt;*/&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data _null_ ;&lt;BR /&gt;declare package sas_ds2.dataset_info f;&lt;BR /&gt;declare char(100) varlistOut;&lt;BR /&gt;method init();&lt;BR /&gt;f = _new_ sas_ds2.dataset_info();&lt;BR /&gt;varlistOut = f.getUnTrimmed();&lt;BR /&gt;put varlistOut;&lt;BR /&gt;* If this and the previous block are uncommented, this step&lt;BR /&gt;does not run and the you get a crash dump;&lt;BR /&gt;/*&lt;BR /&gt;varlistOut = f.getTrimmed();&lt;BR /&gt;put varlistOut;&lt;BR /&gt;*/&lt;BR /&gt;end;&lt;BR /&gt;enddata;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I would probably start by assigning an actual location to the Library Base. Not saying that &lt;STRONG&gt;will&lt;/STRONG&gt; fix things but it may reduce issues with possibly looking in the "wrong" place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't see any Options cmplib statement to tell SAS where compiled functions reside.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681373#M206082</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-03T15:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Functions called in FCMP Functions from DS2 Packages Error: "Freeing Memory Not Allocat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681414#M206104</link>
      <description>&lt;P&gt;That was a really good suggestion, but unfortunately, it did not work.&lt;/P&gt;&lt;P&gt;I think this functionality is handled by the DS2 line "&lt;SPAN&gt;package sql_tools / overwrite=yes language='fcmp' table='base.fcmpsubs';"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am assuming the OPTIONS statement is only needed if calling these functions from open SAS.&amp;nbsp; Please correct me if I am wrong.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 15:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681414#M206104</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-03T15:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Functions called in FCMP Functions from DS2 Packages Error: "Freeing Memory Not Allocat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681449#M206120</link>
      <description>&lt;P&gt;I've not used DS2 except once or twice just to see if it might be a better option than a traditional Data step for a particular project.&amp;nbsp; My experiments with DS2 have uniformly been disappointing.&amp;nbsp; A traditional Data step is almost always faster unless you have a process that is highly CPU bound.&amp;nbsp; If it helps, Troy Martin Hughes wrote a &lt;A href="https://www.pharmasug.org/proceedings/2019/AD/PharmaSUG-2019-AD-228.pdf" target="_blank" rel="noopener"&gt;PharmaSUG paper&lt;/A&gt; that discusses when DS2 actually runs faster than a traditional Data step.&amp;nbsp; When I attended WUSS 2018, one of the speakers said that to his knowledge DS2 really hasn't become popular and that not very many people are using it.&amp;nbsp; My sense is that DS2 has a very narrow range in which it is actually a better option than a traditional Data step or Proc SQL.&amp;nbsp; Incidentally, parallel processing can be done with traditional Data steps either via an rSubmit or via a SYSTASK.&amp;nbsp; However, I think you are interested in DS2 because of it's syntax rather than in its performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, I don't have vast experience from which to draw on re DS2, but I can confirm that an error results.&amp;nbsp; See log below.&amp;nbsp; You may want to do as &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;suggests and open a ticket with SAS.&lt;/P&gt;
&lt;PRE&gt;String to Trim                                                                                      
ERROR: Access violation
ERROR: General error
NOTE: PROC DS2 has set option NOEXEC and will continue to prepare statements.
84         quit;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE DS2 used (Total process time):
      real time           0:00:00.28
      cpu time            0:00:00.28
      Timestamp           September 03, 2020 12:52:30&lt;/PRE&gt;
&lt;P&gt;Jim&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 18:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681449#M206120</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-09-03T18:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Functions called in FCMP Functions from DS2 Packages Error: "Freeing Memory Not Allocat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681464#M206126</link>
      <description>&lt;P&gt;I have submitted this to SAS support.&amp;nbsp; I will update this post with what I learn from them.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Sep 2020 18:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/681464#M206126</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-03T18:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Functions called in FCMP Functions from DS2 Packages Error: "Freeing Memory Not Allocat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/687273#M208626</link>
      <description>&lt;P&gt;Just an update.&amp;nbsp; SAS Tech has been working on this.&amp;nbsp; It looks like they are working on a Hot Fix for M7. I will post the number when I get it.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/687273#M208626</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-09-28T16:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Functions called in FCMP Functions from DS2 Packages Error: "Freeing Memory Not Allocat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/706070#M216684</link>
      <description>&lt;P&gt;SAS has created a hot fix&amp;nbsp;&lt;STRONG&gt;I9S001&lt;/STRONG&gt;&amp;nbsp;for this bug.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find it at&amp;nbsp;&lt;/P&gt;
&lt;PRE width="100"&gt;https://tshf.sas.com/techsup/download/hotfix/HF2/I9R.html#I9S001&lt;/PRE&gt;
&lt;P&gt;I installed it using the standard (and inexcusably difficult) hotfix process.&amp;nbsp; This hotfix is flagged with a "D" in the analysis step which means it needs additional manual steps.&amp;nbsp; My reading of the docs lead me to the conclusion that this is only important if you are in a "Deployed" installation.&amp;nbsp; Since I use a standalone installation of SAS, I did no additional steps and it installed.&amp;nbsp; Note that this hotfix is actually a bundle of two hotfixes&amp;nbsp;&lt;STRONG&gt;I9N001&lt;/STRONG&gt; and &lt;STRONG&gt;I9P001&lt;/STRONG&gt;, so you will not see I9S001 listed in some of the output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tested my original program and it now works correctly!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks SAS support for the relatively fast patch!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 18:07:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Functions-called-in-FCMP-Functions-from-DS2-Packages-Error/m-p/706070#M216684</guid>
      <dc:creator>CurtisMackWSIPP</dc:creator>
      <dc:date>2020-12-15T18:07:28Z</dc:date>
    </item>
  </channel>
</rss>

