Skip to content

[ERROR] getHistoricalRates, memory leak : FATAL ERROR - JavaScript heap out of memory #186

Open
@dawadam

Description

Hi,
I'm trying to retrieve the list of candles.
When the time reaches the "now" time period, the getHistoricalRates method freezes and nodejs has a fatal error :

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Error is not catchable, it's memory leak.

My code is just that :

import { getHistoricalRates } from "dukascopy-node"

// function
const start = async function () {

    // config
    const configRequest: any = {
        instrument: 'eurusd',
        priceType: 'bid',
        dates: { from: 1720100340000, to: 1720112340000 },
        timeframe: 'm1',
        format: 'json',
        useCache: true,
        cacheFolderPath: './cache/dukascopy',
        ignoreFlats: false,
        retryOnEmpty: true,
        retryCount: 2
    }

    // log
    console.log('configRequest', configRequest)

    try {
        // fetching
        const dataBid = await getHistoricalRates(configRequest);
        console.log('dataBid', dataBid)
    } catch (err) {
        console.error(err)
    }

}

// start
start()

It's possible it working now, because the probleme comes from the time :

(dates: { from: 1720100340000, to: 1720112340000 }

The fatal error appears after the "now" time period, please add security to generate a normal catchable error.

Error log if necessary :

<--- Last few GCs --->

[506282:0x74fe0d0]    88578 ms: Scavenge 2039.4 (2074.3) -> 2039.0 (2075.3) MB, 13.15 / 0.00 ms  (average mu = 0.173, current mu = 0.144) allocation failure; 
[506282:0x74fe0d0]    88601 ms: Scavenge 2040.1 (2075.3) -> 2039.7 (2080.5) MB, 12.23 / 0.00 ms  (average mu = 0.173, current mu = 0.144) allocation failure; 


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0xb80c78 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
 2: 0xeee1b0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 3: 0xeee497 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
 4: 0x1100035  [node]
 5: 0x11005c4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
 6: 0x11174b4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
 7: 0x1117ccc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
 8: 0x1119e2a v8::internal::Heap::HandleGCRequest() [node]
 9: 0x1085497 v8::internal::StackGuard::HandleInterrupts() [node]
10: 0x1527bea v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) [node]
11: 0x7efe9de99ef6 
Aborted (core dumped)

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions