Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory not freed

Status
Not open for further replies.

Andreas Oikonomou

Programmer
Nov 28, 2016
1
0
0
GR
In an application I have a task that keeps consuming memory until it crashes. Watching with processExplorer I found that the following function allocates approxmiately 50MB every time it is called (it is called 30 times). This memory is not freed when the function exits, even if I call GarbageCollect. Note that Functions called like Of_IsOrario, Of_GetCell, Of_GetRowCount, Of_GetColCOunt just return values (they do not allocate memory)

Code:
long ll_file, i, j, ll_bytes, ll_fileWithTitles 
double ld_value 
string ls_line 
n_cst_string str 



ll_fileWithTitles = FileOpen( as_fileName + "text.txt", LineMode!, Write!, Shared!, Replace!, EncodingAnsi!) 
ll_file = FileOpen(as_fileName, LineMode!, Write!, Shared!, Replace!, EncodingAnsi!) 

if ll_file < 0 then 
        MessageBox("Σφάλμα", "Could not create file " + as_fileName) 
        return false 
end if 

for i = 1 to Of_GetColCount() 
        if in_tasks[i].Of_IsOrario() then 
                ls_line += "~tO" + in_Tasks[i].is_symbol 
        else 
                ls_line += "~t" + in_Tasks[i].is_symbol 
        end if                 
next 
FileWrite(ll_fileWithTitles, ls_line) 

for i = 1 to Of_GetRowCount() 
        ls_line = "" 
        for j = 1 to Of_GetColCount() 
                ld_value = -Of_GetCell(i, j) 

                if ls_line <> "" then ls_line += "~t" 
                ls_line += string(ld_value) 
        next 
        ls_line = str.Of_GlobalReplace(ls_line, ",", ".") 
        if IsNull(ls_line) then 
                ls_line = ls_line 
        end if 
        ll_bytes = FileWrite(ll_file, ls_line) 
        ls_line = string(in_matrix[i].il_agentId) + "~t" + ls_line 
        ll_bytes = FileWrite(ll_fileWithTitles, ls_line) 
next 
                 
FileClose(ll_file) 
FileClose(ll_fileWithTitles) 

return true
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top