Skip to content

Commit

Permalink
Try to free data to collect front-end garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Apr 8, 2016
1 parent fd246e8 commit fc4de9e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 3rdParty
Submodule 3rdParty updated 1 files
+3 −0 .gitignore
10 changes: 7 additions & 3 deletions Compiler/SimCode/SimCodeMain.mo
Expand Up @@ -787,18 +787,22 @@ algorithm
ExecStat.execStat("Transformations before backend");
description = DAEUtil.daeDescription(dae);
dlow = BackendDAECreate.lower(dae, cache, graph, BackendDAE.EXTRA_INFO(description,filenameprefix));

GC.free(dae);
graph = FCore.EG("<EMPTY>");

//BackendDump.printBackendDAE(dlow);
(dlow_1, initDAE, useHomotopy, initDAE_lambda0, removedInitialEquationLst, primaryParameters, allPrimaryParameters) = BackendDAEUtil.getSolvedSystem(dlow,inFileNamePrefix);
(dlow, initDAE, useHomotopy, initDAE_lambda0, removedInitialEquationLst, primaryParameters, allPrimaryParameters) = BackendDAEUtil.getSolvedSystem(dlow,inFileNamePrefix);
timeBackend = System.realtimeTock(ClockIndexes.RT_CLOCK_BACKEND);

(libs, file_dir, timeSimCode, timeTemplates) =
generateModelCode(dlow_1, initDAE, useHomotopy, initDAE_lambda0, removedInitialEquationLst, primaryParameters, allPrimaryParameters, p, className, filenameprefix, inSimSettingsOpt, args);
generateModelCode(dlow, initDAE, useHomotopy, initDAE_lambda0, removedInitialEquationLst, primaryParameters, allPrimaryParameters, p, className, filenameprefix, inSimSettingsOpt, args);

resultValues = {("timeTemplates", Values.REAL(timeTemplates)),
("timeSimCode", Values.REAL(timeSimCode)),
("timeBackend", Values.REAL(timeBackend)),
("timeFrontend", Values.REAL(timeFrontend))};
then (cache, st, dlow_1, libs, file_dir, resultValues);
then (cache, st, dlow, libs, file_dir, resultValues);

case (_, _, _, _, _, _, _, _) equation
true = Flags.isSet(Flags.FAILTRACE);
Expand Down
17 changes: 16 additions & 1 deletion Compiler/Util/GC.mo
Expand Up @@ -49,7 +49,22 @@ end disable;

function free<T>
input T data;
external "C" GC_free(data) annotation(Library = {"omcgc"});
external "C" omc_GC_free_ext(data) annotation(Include="
void omc_GC_free_ext(void *data)
{
/* */
GC_free(MMC_UNTAGPTR(data));
}
",
Library = {"omcgc"}, Documentation(info="<html>
<p>GC_free requires \"a pointer to the base of an object\".</p>
<p>So the object passed to free must not be allocated by any of the list
routines that allocate multiple elements with a single malloc call.</p>
<p>Calling GC.free is very dangerous. You might be better off trying to
set variables to a constant value if you want to GC them. Use this if
you are concerned about temporary variables, etc remaining on the stack
and not cleared for a long time.</p>
</html>"));
end free;

function expandHeap
Expand Down

0 comments on commit fc4de9e

Please sign in to comment.