我已经调用了高达2048(mb?)的节点没有任何成功,所以在这一点上,我认为继续提高内存限制是没有意义的,特别是如果我的代码一开始效率很低的话。这是致命错误的答案:无效的标记压缩接近堆限制分配失败-尽管在ionic 3中JavaScript堆内存不足。
ref:节点——最大旧空间大小=2048
由于不够简洁:
<--- Last few GCs --->
io[5481:0x5693440] 286694 ms: Mark-sweep 2048.0 (2051.1) -> 2047.3 (2051.3) MB, 1268.3 / 0.0 ms (+ 0.0 ms in 13 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1272 ms) (average mu = 0.087, current mu = 0.003) allocatio[5481:0x
5693440] 290098 ms: Mark-sweep 2048.2 (2051.3) -> 2047.5 (2051.3) MB, 3398.6 / 0.0 ms (+ 0.0 ms in 13 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 3404 ms) (average mu = 0.026, current mu = 0.002) allocatio
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xa2b020 node::Abort() [node]
2: 0x97a467 node::FatalError(char const*, char const*) [node]
3: 0xb9e0ee v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xb9e467 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xd3e875 [node]
6: 0xd3f21b v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
7: 0xd4d012 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
8: 0xd4de65 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
9: 0xd5082c v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0xd1fecb v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
11: 0x10501ef v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
12: 0x13a9ed9 [node]
Aborted
npm ERR! code ELIFECYCLE
下面是我的问题函数:
public async upsertToDb(courses: Record<string, Record<string, any>>): Promise<string> {
this.courseTransformationUtility.transformToFlatStructure(courses);
const flatCourses: Array<Course> = this.courseTransformationUtility.getFlatCourses();
const flatClasses: Array<Class> = this.courseTransformationUtility.getFlatClasses();
console.info(`Courses exploded into ${flatCourses.length} rows.`)
console.info(`Classes exploded into ${flatClasses.length} rows.`)
await this._deleteTable("Course");
await this._deleteTable("Class");
for(let i = 0; i < flatCourses.length; i+=100) {
Backendless.Data.of(Course).bulkCreate(flatCourses.slice(i, i + 100))
.then(() => {
process.stdout.write(".");
})
.catch((e: Error) => console.info(e));
}
for(let i = 0; flatClasses.length; i+=100) {
Backendless.Data.of(Class).bulkCreate(flatClasses.slice(i, i + 100))
.then(() => {
process.stdout.write(".");
})
.catch((e: Error) => console.info(e));
}
return "";
}
如果我注释掉第二个循环节点,它将在默认内存设置下运行,而不会出现任何问题。如果我不得不猜测这个问题与异步有关,但我真的不能确定。如果这是一个问题,我们是否可以将其反异步化?对不起,这里有很多问题我没有深度来回答。
romise.all不是解决办法,至少对我来说。
for(let i = 0; i < flatCourses.length; i+=100) {
let promise: Promise<Array<string>> = Backendless.Data.of(Course).bulkCreate(flatCourses.slice(i, i + 100));
promise.then(() => process.stdout.write('.'));
coursePromises.push(promise);
}
await Promise.all(coursePromises.slice(0, Math.floor(coursePromises.length/2))).then(() => console.info("1/4"));
await Promise.all(coursePromises.slice(Math.floor(coursePromises.length/2))).then(() => console.info("2/4"));
for(let i = 0; flatClasses.length; i+=100) {
let promise: Promise<Array<string>> = Backendless.Data.of(Class).bulkCreate(flatClasses.slice(i, i + 100));
promise.then(() => process.stdout.write('.'));
classPromises.push(promise);
}
await Promise.all(classPromises.slice(0, Math.floor(classPromises.length/2))).then(() => console.info("3/4"));
await Promise.all(classPromises.slice(Math.floor(classPromises.length/2))).then(() => console.info("4/4"));
登录中
Using term 202008...
Publishing 2113 courses...
Courses exploded into 11630 rows.
Classes exploded into 10986 rows.
....................................................................................................................1/4
.2/4
<--- Last few GCs --->
io[5628:0x5a47390] 310095 ms: Mark-sweep 2047.4 (2050.7) -> 2046.7 (2051.0) MB, 1935.6 / 0.0 ms (+ 0.0 ms in 14 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1941 ms) (average mu = 0.117, current mu = 0.003) allocatio[5628:0x
5a47390] 311960 ms: Mark-sweep 2047.6 (2051.0) -> 2046.9 (2051.2) MB, 1860.4 / 0.0 ms (+ 0.0 ms in 13 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1865 ms) (average mu = 0.063, current mu = 0.003) allocatio
<--- JS stacktrace --->
您没有阻塞任何异步代码,因此所有异步代码都会立即启动并占用内存。一个临时解决方案是使用wait而不是then。更全面的解决方案将涉及批处理调用和使用Promie。所有这些都是为了解决批处理问题。
你可以一次做一个异步操作,或者一次做一个课程和类。
每件事都是一次一件。
js prettyprint-override">for (let i = 0; i < flatCourses.length; i+=100) {
try {
await Backendless.Data.of(Course).bulkCreate(flatCourses.slice(i, i + 100))
process.stdout.write(".");
} catch (e) {
console.info(e)
}
}
// Do the same for flatClasses
课程和课程一次一个
const promises = []
for (let i = 0; i < flatCourses.length; i+=100) {
const promise = Backendless.Data.of(Course).bulkCreate(flatCourses.slice(i, i + 100))
promise.then(() => {
process.stdout.write(".");
})
.catch((e: Error) => console.info(e));
promises.push(promise)
}
await Promise.all(promises)
// Do the same for flatClasses
更复杂的方法涉及一次做N个操作,但是如果这些简单的方法解决了你的问题,我不会走那么远。
我试图用Selenium×Node.js实现自动化测试,但它在调查阶段被阻止了... Mac OS10.12.6 节点8.11.1 Selenium Server 3.12.0 Selenium WebDriver 4.0.0 ChromeDriver 2.38 3.安装selenium-server 通过自制安装 4.安装ChromeDriver $selenium-server-port 44
我想知道是否有办法简化这个?我是Java流的新手,我尝试使用Map,但我使用了传统的for循环。
我想使用以下循环创建一个新列。表中只有“open”和“start”列。我想创建一个新列“startopen”,如果“start”等于1,那么“startopen”等于“open”。否则,“startopen”等于此新创建列上方行中的任何“startopen”。目前,我能够通过以下方式实现这一点: 这有效,但对于大型数据集来说非常慢。是否有任何内置函数可以更快地完成此操作?
我正在寻找一个潜在的黑客在我的应用程序中,我无法获得onReceive()或sms_send或SMS_DELIVERED在设备,如Oppo,Vivo,MI。
由于没有快速的lambda计算器,我使用上面的策略将非类型化lambda演算的术语编译为Haskell,以便快速计算它们。我对它的性能印象深刻:该程序创建了一个从到的数字列表,并在我的计算机上在不到一秒钟的时间内将它们相加。这比我预期的要快得多--只比Haskell直接等价物慢4倍--并且足以对我的目标有用。但是,请注意,为了满足类型系统的需要,我必须将函数和术语包装在fun/num构造函数下面。
下面的代码在执行时会产生堆栈溢出错误。然而,如果移除其中任何一个