-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript is crashed by using too much memory #9052
Comments
The source of the regression was #8713 |
v1.8.10 has a same problem, and sometimes v1.8.30 with VS2015 will be crashed a few minutes later. So I feel this problem has another reason different from #8713. |
In 1.8.10, i see it finishing up compilation in less than 10 secs, but uses about 1 GB of memory. this commit is when it started to crash the compiler. In general, these complex recursive definitions like the ones in https://github.com/falsandtru/spica/blob/v0.0.6/src/lib/monad/sequence.ts, do not fare well in a structural type system. the system needs to relate these generic types structurally, and every time it descends into these types, it instantiates their method signatures, which include other generic types, and so on. This is similar to the issues we ran into with RxJS a while back, see #7344. the fix was to simplify the complexity of these types to avoid the expensive comparisons, see ReactiveX/rxjs#1475. |
In short, crashes of VS won't be fixed? VS uses 2.5~3.0GB of memory. |
I found a solution. before:
after: - export class Sequence<T, S> extends Monad<T> implements ISequence<T, S> {
+ export class Sequence<T, S> extends Monad<T> {
Is this a correct behavior? It seems to leak Symbols and Types. I think, interfaces shouldn't impair the performance. |
What do you mean by leak symbols? |
The compiler uses too many symbols, types, memory and Check time only for implementation of interfaces. - export class Sequence<T, S> extends Monad<T> implements ISequence<T, S> {
+ export class Sequence<T, S> extends Monad<T> { - Symbols: 1964595
+ Symbols: 892012
- Types: 529786
+ Types: 41074
- Memory used: 828809K
+ Memory used: 119040K
- Check time: 28.43s
+ Check time: 5.84s |
Actually
In my testing, spica v0.0.6 still crashes node even with these |
I want to ensure type consistency of declaration( |
In the original code, For example, compile with |
Thanks for the explanation. But I want to manage and design .d.ts file manually because I'm using .d.ts file for API documentation and API visibility control. If you remove the way to ensure type consistency of the implementation with the declaration, it is truly unfortunate. |
I see. You're right, I misread the code -- it's not circular but goes to the d.ts. Unfortunately, typescript definitely does lots of computation to check that two complex structures are structurally identical. I'm not sure there's a way to get around that and still make sure that your implementation perfectly matches your interface. |
Thanks, I'm waiting for the results of your investigation. |
@sandersn Any updates? I'm stuck by this bug. Please fix it. |
Unfortunately, we just can't support structural comparison of two gigantic, identical types in the compiler as it is today. The optimisation that I removed in #8713 is incorrect and skips checks that should actually happen. Efficiency would have to come from elsewhere. The bottom line is that TypeScript can't support your d.ts-checked workflow for this library. As a workaround, you'll have to stop the d.ts-checking or simplify the types somehow. |
@sandersn This overflow is caused even when I don't use .d.ts files and an |
I'm not clear what is structural comparison of two gigantic identical types? I removed checks using |
I found another case that is not used structural comparisons. |
This crash is caused by a few codes. Is this correct behavior?
TypeScript Version:
1.9.0-dev.20160609
Code
https://github.com/falsandtru/spica/tree/v0.0.6
https://travis-ci.org/falsandtru/spica/builds/136372602
https://github.com/falsandtru/spica/blob/v0.0.6/src/lib/monad/sequence.ts
The text was updated successfully, but these errors were encountered: