mirror of https://gitlab.com/basile.b/dexed.git
fix #38 - D GC memory still not enough released to the OS
This commit is contained in:
parent
fd770a0fb2
commit
0c17a4d187
|
@ -12,15 +12,15 @@ import
|
||||||
|
|
||||||
extern(C) void setRtOptions()
|
extern(C) void setRtOptions()
|
||||||
{
|
{
|
||||||
import core.gc.config : config;
|
//import core.gc.config : config;
|
||||||
config.gc = "precise";
|
//config.gc = "precise";
|
||||||
}
|
}
|
||||||
|
|
||||||
extern(C) void minimizeGcHeap()
|
extern(C) void minimizeGcHeap()
|
||||||
{
|
{
|
||||||
import core.memory : GC;
|
import core.memory : GC;
|
||||||
__gshared ubyte c;
|
__gshared ubyte c;
|
||||||
if (c++ > 96)
|
if (c++ > 32)
|
||||||
{
|
{
|
||||||
GC.collect();
|
GC.collect();
|
||||||
GC.minimize();
|
GC.minimize();
|
||||||
|
|
|
@ -6,7 +6,7 @@ import
|
||||||
std.array, std.traits, std.conv, std.json, std.format,
|
std.array, std.traits, std.conv, std.json, std.format,
|
||||||
std.algorithm, std.string;
|
std.algorithm, std.string;
|
||||||
import
|
import
|
||||||
iz.memory: construct, destruct;
|
iz.memory: construct, destruct, MustAddGcRange, TellRangeAdded, NoGc;
|
||||||
import
|
import
|
||||||
iz.containers : Array;
|
iz.containers : Array;
|
||||||
import
|
import
|
||||||
|
@ -34,9 +34,9 @@ extern(C) const(char)* listSymbols(const(char)* src, bool deep)
|
||||||
errors ~= construct!(AstError)(cast(ErrorType) err, message, line, col);
|
errors ~= construct!(AstError)(cast(ErrorType) err, message, line, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
LexerConfig config;
|
scope LexerConfig config;
|
||||||
RollbackAllocator rba;
|
scope RollbackAllocator rba;
|
||||||
StringCache sCache = StringCache(StringCache.defaultBucketCount);
|
scope StringCache sCache = StringCache(StringCache.defaultBucketCount);
|
||||||
|
|
||||||
scope mod = src[0 .. src.strlen]
|
scope mod = src[0 .. src.strlen]
|
||||||
.getTokensForParser(config, &sCache)
|
.getTokensForParser(config, &sCache)
|
||||||
|
@ -44,10 +44,17 @@ extern(C) const(char)* listSymbols(const(char)* src, bool deep)
|
||||||
|
|
||||||
alias SL = SymbolListBuilder!(ListFmt.Pas);
|
alias SL = SymbolListBuilder!(ListFmt.Pas);
|
||||||
SL sl = construct!(SL)(errors, deep);
|
SL sl = construct!(SL)(errors, deep);
|
||||||
scope(exit) destruct(sl);
|
scope(exit)
|
||||||
|
{
|
||||||
|
destruct(sl);
|
||||||
|
destroy(errors);
|
||||||
|
destroy(sCache);
|
||||||
|
destroy(rba);
|
||||||
|
}
|
||||||
|
|
||||||
sl.visit(mod);
|
sl.visit(mod);
|
||||||
return sl.serialize();
|
const(char)* result = sl.serialize();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -87,13 +94,15 @@ string makeSymbolTypeArray()
|
||||||
|
|
||||||
mixin(makeSymbolTypeArray);
|
mixin(makeSymbolTypeArray);
|
||||||
|
|
||||||
final class SymbolListBuilder(ListFmt Fmt): ASTVisitor
|
static assert (!MustAddGcRange!(SymbolListBuilder!(ListFmt.Pas)));
|
||||||
|
|
||||||
|
@TellRangeAdded final class SymbolListBuilder(ListFmt Fmt): ASTVisitor
|
||||||
{
|
{
|
||||||
private immutable bool _deep;
|
private immutable bool _deep;
|
||||||
|
|
||||||
static if (Fmt == ListFmt.Pas)
|
static if (Fmt == ListFmt.Pas)
|
||||||
{
|
{
|
||||||
Appender!(char[]) pasStream;
|
Array!char pasStream;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -108,7 +117,6 @@ final class SymbolListBuilder(ListFmt Fmt): ASTVisitor
|
||||||
this(Appender!(AstErrors) errors, bool deep)
|
this(Appender!(AstErrors) errors, bool deep)
|
||||||
{
|
{
|
||||||
_deep = deep;
|
_deep = deep;
|
||||||
funcNameApp.length = 0;
|
|
||||||
static if (Fmt == ListFmt.Pas)
|
static if (Fmt == ListFmt.Pas)
|
||||||
{
|
{
|
||||||
pasStream.put("object TSymbolList\rsymbols=<");
|
pasStream.put("object TSymbolList\rsymbols=<");
|
||||||
|
@ -122,6 +130,16 @@ final class SymbolListBuilder(ListFmt Fmt): ASTVisitor
|
||||||
addAstErrors(errors.data);
|
addAstErrors(errors.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~this()
|
||||||
|
{
|
||||||
|
destruct(funcNameApp);
|
||||||
|
destruct(fmtVisitor);
|
||||||
|
static if (Fmt == ListFmt.Pas)
|
||||||
|
{
|
||||||
|
destruct(pasStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
alias visit = ASTVisitor.visit;
|
alias visit = ASTVisitor.visit;
|
||||||
|
|
||||||
void addAstErrors(AstErrors errors)
|
void addAstErrors(AstErrors errors)
|
||||||
|
@ -156,8 +174,8 @@ final class SymbolListBuilder(ListFmt Fmt): ASTVisitor
|
||||||
{
|
{
|
||||||
static if (Fmt == ListFmt.Pas)
|
static if (Fmt == ListFmt.Pas)
|
||||||
{
|
{
|
||||||
pasStream.put(">\rend");
|
pasStream.put(">\rend\0");
|
||||||
return pasStream.data.toStringz;
|
return cast(typeof(return))pasStream[].dup.ptr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -419,8 +437,21 @@ final class SymbolListBuilder(ListFmt Fmt): ASTVisitor
|
||||||
otherVisitorImpl(decl, SymbolType._function, "shared static dtor", decl.line, decl.column);
|
otherVisitorImpl(decl, SymbolType._function, "shared static dtor", decl.line, decl.column);
|
||||||
}
|
}
|
||||||
|
|
||||||
override void visit(const Expression){}
|
override void visit(const Expression) {}
|
||||||
override void visit(const ExpressionNode){}
|
override void visit(const ExpressionNode) {}
|
||||||
override void visit(const ExpressionStatement){}
|
override void visit(const ExpressionStatement) {}
|
||||||
|
override void visit(const PragmaStatement) {}
|
||||||
|
override void visit(const Initializer) {}
|
||||||
|
override void visit(const FunctionContract) {}
|
||||||
|
override void visit(const AsmStatement) {}
|
||||||
|
override void visit(const ReturnStatement) {}
|
||||||
|
override void visit(const BreakStatement) {}
|
||||||
|
override void visit(const ContinueStatement) {}
|
||||||
|
override void visit(const GotoStatement) {}
|
||||||
|
override void visit(const MixinDeclaration) {}
|
||||||
|
override void visit(const Type) {}
|
||||||
|
override void visit(const Type2) {}
|
||||||
|
override void visit(const StaticAssertStatement){}
|
||||||
|
override void visit(const StaticAssertDeclaration){}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue